Example #1
0
        void GUIToolSelection()
        {
            foldoutTool = EditorGUILayout.Foldout(foldoutTool, "Tools");
            if (!foldoutTool)
            {
                return;
            }

            if (tool == null)
            {
                GUILayout.Label("None");
            }
            else
            {
                GUILayout.Label(tool.GetType().Name);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginDisabledGroup(tool.GetType().Name == "Brush");
            if (GUILayout.Button("Brush"))
            {
                tool = new Brush();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUI.BeginDisabledGroup(tool.GetType().Name == "Line");
            if (GUILayout.Button("Line"))
            {
                tool = new Line();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUI.BeginDisabledGroup(tool.GetType().Name == "Box");
            if (GUILayout.Button("Box"))
            {
                tool = new Box();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUI.BeginDisabledGroup(tool.GetType().Name == "Cylinder");
            if (GUILayout.Button("Cylinder"))
            {
                tool = new Cylinder();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUI.BeginDisabledGroup(tool.GetType().Name == "Sphere");
            if (GUILayout.Button("Sphere"))
            {
                tool = new Sphere();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUI.BeginDisabledGroup(tool.GetType().Name == "Laser");
            if (GUILayout.Button("Laser"))
            {
                tool = new Laser();
            }

            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Fill"))
            {
                //Undo.RecordObject(voxelMesh, "Fill VoxelMesh");
                //EditorUtility.SetDirty(voxelMesh);
                voxelMesh.Fill(true);
            }

            if (GUILayout.Button("Empty"))
            {
                //Undo.RecordObject(voxelMesh, "Empty VoxelMesh");
                //EditorUtility.SetDirty(voxelMesh);
                voxelMesh.Fill(false);
            }

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Save"))
            {
                EditorUtility.SetDirty(voxelMesh);
                SerializedObject serializedObject = new SerializedObject(voxelMesh);
                serializedObject.ApplyModifiedProperties();
            }
            if (GUILayout.Button("Refresh"))
            {
                if (voxelMesh != null)
                {
                    //Undo.RecordObject(voxelMesh, "VoxelMesh");
                    voxelMesh.Refresh();
                }
            }

            EditorGUILayout.EndHorizontal();
        }