Exemple #1
0
        static void OnBottomBarUIFunction(int windowID)
        {
            EditorGUI.BeginChangeCheck();
            GUILayout.BeginHorizontal();

            // TODO: assign hotkey to rebuild, and possibly move it elsewhere to avoid it seemingly like a necessary action.
            if (GUILayout.Button(rebuildButton, ChiselSceneGUIStyle.buttonStyle))
            {
                Rebuild();
            }

            GUILayout.FlexibleSpace();

            ChiselEditorSettings.ShowGrid = GUILayout.Toggle(ChiselEditorSettings.ShowGrid, "Show Grid", ChiselSceneGUIStyle.toggleStyle);

            ChiselEditorSettings.UniformSnapDistance = EditorGUILayout.FloatField(ChiselEditorSettings.UniformSnapDistance, floatWidthLayout);
            if (GUILayout.Button(halveSnapDistanceButton, EditorStyles.miniButtonLeft, sizeButtonWidth))
            {
                SnappingKeyboard.HalfGridSize();
            }
            if (GUILayout.Button(doubleSnapDistanceButton, EditorStyles.miniButtonRight, sizeButtonWidth))
            {
                SnappingKeyboard.DoubleGridSize();
            }

            GUILayout.EndHorizontal();
            if (EditorGUI.EndChangeCheck())
            {
                ChiselEditorSettings.Save();
            }
        }
        public static void Initialize()
        {
            // Update loop
            UnityEditor.EditorApplication.update -= OnEditorApplicationUpdate;
            UnityEditor.EditorApplication.update += OnEditorApplicationUpdate;

            // Called after prefab instances in the scene have been updated.
            UnityEditor.PrefabUtility.prefabInstanceUpdated -= OnPrefabInstanceUpdated;
            UnityEditor.PrefabUtility.prefabInstanceUpdated += OnPrefabInstanceUpdated;

            // OnGUI events for every visible list item in the HierarchyWindow.
            UnityEditor.EditorApplication.hierarchyWindowItemOnGUI -= OnHierarchyWindowItemOnGUI;
            UnityEditor.EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyWindowItemOnGUI;

            // Triggered when currently active/selected item has changed.
            UnityEditor.Selection.selectionChanged -= OnSelectionChanged;
            UnityEditor.Selection.selectionChanged += OnSelectionChanged;

            // Triggered when currently active/selected item has changed.
            CSGSurfaceSelectionManager.selectionChanged -= OnSurfaceSelectionChanged;
            CSGSurfaceSelectionManager.selectionChanged += OnSurfaceSelectionChanged;
            CSGSurfaceSelectionManager.hoverChanged     -= OnSurfaceHoverChanged;
            CSGSurfaceSelectionManager.hoverChanged     += OnSurfaceHoverChanged;

            // A callback to be raised when an object in the hierarchy changes.
            // Each time an object is (or a group of objects are) created,
            // renamed, parented, unparented or destroyed this callback is raised.
//			UnityEditor.EditorApplication.hierarchyWindowChanged		-= OnHierarchyWindowChanged;
//			UnityEditor.EditorApplication.hierarchyWindowChanged		+= OnHierarchyWindowChanged;

            UnityEditor.EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
            UnityEditor.EditorApplication.playModeStateChanged += OnPlayModeStateChanged;

            // Callback that is triggered after an undo or redo was executed.
            UnityEditor.Undo.undoRedoPerformed -= OnUndoRedoPerformed;
            UnityEditor.Undo.undoRedoPerformed += OnUndoRedoPerformed;

            UnityEditor.Undo.postprocessModifications -= OnPostprocessModifications;
            UnityEditor.Undo.postprocessModifications += OnPostprocessModifications;

#if UNITY_2019_1_OR_NEWER
            UnityEditor.SceneView.duringSceneGui -= OnSceneGUI;
            UnityEditor.SceneView.duringSceneGui += OnSceneGUI;
#else
            UnityEditor.SceneView.onSceneGUIDelegate -= OnSceneGUI;
            UnityEditor.SceneView.onSceneGUIDelegate += OnSceneGUI;
#endif

            CSGNodeHierarchyManager.NodeHierarchyReset -= OnHierarchyReset;
            CSGNodeHierarchyManager.NodeHierarchyReset += OnHierarchyReset;

            CSGNodeHierarchyManager.NodeHierarchyModified -= OnNodeHierarcyModified;
            CSGNodeHierarchyManager.NodeHierarchyModified += OnNodeHierarcyModified;

            CSGNodeHierarchyManager.TransformationChanged -= OnTransformationChanged;
            CSGNodeHierarchyManager.TransformationChanged += OnTransformationChanged;

            CSGGeneratedModelMeshManager.PostUpdateModels -= OnPostUpdateModels;
            CSGGeneratedModelMeshManager.PostUpdateModels += OnPostUpdateModels;

            CSGGeneratedModelMeshManager.PostReset -= OnPostResetModels;
            CSGGeneratedModelMeshManager.PostReset += OnPostResetModels;

            CSGEditModeManager.EditModeChanged -= OnEditModeChanged;
            CSGEditModeManager.EditModeChanged += OnEditModeChanged;
            CSGEditModeManager.Init();

            SnappingKeyboard.Init();

            CSGClickSelectionManager.Instance.OnReset();
            CSGOutlineRenderer.Instance.OnReset();

            // TODO: clean this up
            CSGGeneratorComponent.GetSelectedVariantsOfBrushOrSelf = CSGSyncSelection.GetSelectedVariantsOfBrushOrSelf;
        }