Ejemplo n.º 1
0
        private void AdaptCollider(GeneratedRect targetRect, RectMeshGenerator meshGenerator)
        {
            BoxCollider col = targetRect.GetComponent <BoxCollider>();

            if (col != null)
            {
                Undo.RecordObject(col, "Collider bounds change");
                meshGenerator.AssignRectVariables(col);
                meshGenerator.AdjustCollider(col, heightProperty.floatValue);
            }
        }
Ejemplo n.º 2
0
        private void RecreateRect(GeneratedRect targetRect)
        {
            float x, z, height;

            AssignSizeValues(targetRect, out x, out z, out height);

            RectMeshGenerator meshGenerator = new RectMeshGenerator(x, z, height);

            meshGenerator.CreateRect();
            Mesh newMesh = meshGenerator.GetMesh();

            SetNewMesh(targetRect, newMesh);
            AdaptCollider(targetRect, meshGenerator);

            targetRect.Uvs = meshGenerator.GetUVs();
        }
        private void DrawInputFields()
        {
            x = EditorGUI.FloatField(new Rect(0, 120, position.width, 15), "X", x);
            z = EditorGUI.FloatField(new Rect(0, 140, position.width, 15), "Z", z);
            colliderHeight = EditorGUI.FloatField(new Rect(0, 160, position.width, 15), "Collider Height", colliderHeight);

            generateUVMap = EditorGUI.Toggle(new Rect(0, 220, position.width, 15), "Generate UV Map", generateUVMap);
            uvSize        = EditorGUI.IntField(new Rect(0, 240, position.width, 15), "UV size", uvSize);

            if (GUILayout.Button("Create Rect"))
            {
                RectMeshGenerator meshGenerator = new RectMeshGenerator(x, z, colliderHeight);

                meshGenerator.CreateRect();
                meshGenerator.CreateNewObject();
                meshGenerator.SetParent(Selection.activeTransform);
                List <Vector2> uvs = meshGenerator.GetUVs();

                if (Selection.activeTransform == null)
                {
                    output = SUCCESS_MESSAGE + ROOT_NAME + DOT_SPACE;
                }
                else
                {
                    output = SUCCESS_MESSAGE + Selection.activeTransform.gameObject.name + DOT_SPACE;
                }

                if (generateUVMap)
                {
                    UVBitmapGenerator generator = new UVBitmapGenerator();
                    output += generator.StoreUVMap(uvs, uvSize);
                    AssetDatabase.Refresh();
                }
            }

            GUILayout.Box(output);
        }