コード例 #1
0
        static void OnBottomBarUI(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, buttonStyle))
            {
                Rebuild();
            }

            GUILayout.FlexibleSpace();

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

            CSGEditorSettings.UniformSnapDistance = EditorGUILayout.FloatField(CSGEditorSettings.UniformSnapDistance, floatWidthLayout);
            if (GUILayout.Button(halveSnapDistanceButton, EditorStyles.miniButtonLeft))
            {
                MultiplySnapDistance(0.5f);
            }
            if (GUILayout.Button(doubleSnapDistanceButton, EditorStyles.miniButtonRight))
            {
                MultiplySnapDistance(2.0f);
            }

            GUILayout.EndHorizontal();
            if (EditorGUI.EndChangeCheck())
            {
                CSGEditorSettings.Save();
            }
        }
コード例 #2
0
        static void OnWindowGUI(Rect position)
        {
            var togglePosition = position;

            togglePosition.height = kSingleLineHeight;
            for (int i = 0; i < editModes.Length; i++)
            {
                var editMode = editModes[i];
                EditorGUI.BeginChangeCheck();
                var value = GUI.Toggle(togglePosition, CSGEditModeManager.EditMode == editMode.value, editMode.content, GUI.skin.button);
                if (EditorGUI.EndChangeCheck() && value)
                {
                    // If we're changing edit mode from a generator, we restore our previous selection.
                    if (Instance.HaveSelection())
                    {
                        Instance.RestoreSelection(skipEditMode: true);
                    }
                    CSGEditModeManager.EditMode = editMode.value;
                    CSGEditorSettings.Save();
                }
                togglePosition.y += kSingleLineHeight + kSingleSpacing;
            }

            togglePosition.y += kGeneratorSeparator;

            for (int i = 0; i < generatorModes.Length; i++)
            {
                var editMode = generatorModes[i];
                EditorGUI.BeginChangeCheck();
                var value = GUI.Toggle(togglePosition, CSGEditModeManager.EditMode == editMode.value, editMode.content, GUI.skin.button);
                if (EditorGUI.EndChangeCheck() && value)
                {
                    // When we select a generator, we don't want anything else selected since the combination makes no sense.
                    // We store the selection, however, if our previous edit mode was not a generator.
                    if (CSGEditModeManager.EditMode < CSGEditMode.FirstGenerator)
                    {
                        Instance.RememberSelection();
                    }
                    CSGEditModeManager.EditMode = editMode.value;
                    CSGEditorSettings.Save();
                }
                togglePosition.y += kSingleLineHeight + kSingleSpacing;
            }
        }
コード例 #3
0
        private static void GridOnSceneGUI(SceneView sceneView)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            if (ShowUnityGrid)
            {
                ShowUnityGrid = false;
                CSGEditorSettings.Load();
                CSGEditorSettings.ShowGrid = false;
                CSGEditorSettings.Save();
            }

            if (Tools.pivotRotation == PivotRotation.Local)
            {
                var activeTransform = Selection.activeTransform;

                var rotation = Tools.handleRotation;
                var center   = (activeTransform && activeTransform.parent) ? activeTransform.parent.position : Vector3.zero;

                UnitySceneExtensions.Grid.defaultGrid.GridToWorldSpace = Matrix4x4.TRS(center, rotation, Vector3.one);
            }
            else
            {
                UnitySceneExtensions.Grid.defaultGrid.GridToWorldSpace = Matrix4x4.identity;
            }

            if (CSGEditorSettings.ShowGrid)
            {
                var grid = UnitySceneExtensions.Grid.HoverGrid;
                if (grid == null)
                {
                    grid = UnitySceneExtensions.Grid.ActiveGrid;
                }
                grid.Render(sceneView);
            }
        }
コード例 #4
0
        private static void OnKeyboardEventCalled(KeyEventType type)
        {
            switch (type)
            {
            case KeyEventType.HalfGridSizeKey:                      CSGSceneBottomGUI.MultiplySnapDistance(0.5f); break;

            case KeyEventType.DoubleGridSizeKey:            CSGSceneBottomGUI.MultiplySnapDistance(2.0f); break;

            // TODO: turn this into utility functions that are shared with CSGSceneBottomGUI
            case KeyEventType.ToggleBoundsSnappingKey:      CSGEditorSettings.PivotSnapping = !CSGEditorSettings.PivotSnapping; CSGEditorSettings.Save(); break;

            case KeyEventType.TogglePivotSnappingKey:       CSGEditorSettings.BoundsSnapping = !CSGEditorSettings.BoundsSnapping; CSGEditorSettings.Save(); break;

            case KeyEventType.ToggleShowGridKey:            CSGEditorSettings.ShowGrid = !CSGEditorSettings.ShowGrid; CSGEditorSettings.Save(); break;
            }
        }