Example #1
0
        private void DrawCheckUncheckAllDblSlidersVisButtons(UnityEngine.Object undoRecordObject)
        {
            EditorGUILayout.BeginHorizontal();
            var content = new GUIContent();

            content.text    = "Show all";
            content.tooltip = "Show all double-axis sliders.";
            if (GUILayout.Button(content, GUILayout.Width(80.0f)))
            {
                EditorUndoEx.Record(undoRecordObject);
                for (int index = 0; index < _dblSliderVis.Length; ++index)
                {
                    _dblSliderVis[index] = true;
                }
            }

            content.text    = "Hide all";
            content.tooltip = "Hide all double-axis sliders.";
            if (GUILayout.Button(content, GUILayout.Width(80.0f)))
            {
                EditorUndoEx.Record(undoRecordObject);
                for (int index = 0; index < _dblSliderVis.Length; ++index)
                {
                    _dblSliderVis[index] = false;
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            EditorGUILayout.BeginVertical();
            var content = new GUIContent();

            content.text    = "Move speed";
            content.tooltip = "Allows you to specify the speed that is used to move the camera in the scene (defualt keys: WASDQE + RMB). The value is expressed in world units/second.";
            float newFloat = EditorGUILayout.FloatField(content, MoveSpeed);

            if (newFloat != MoveSpeed)
            {
                EditorUndoEx.Record(undoRecordObject);
                MoveSpeed = newFloat;
            }

            content.text    = "Acceleration rate";
            content.tooltip = "When moving the camera around, an acceleration will be applied to the camera move speed. This field " +
                              "allows you to control how fast the acceleration increases.";
            newFloat = EditorGUILayout.FloatField(content, AccelerationRate);
            if (newFloat != AccelerationRate)
            {
                EditorUndoEx.Record(undoRecordObject);
                AccelerationRate = newFloat;
            }
            EditorGUILayout.EndVertical();
        }
Example #3
0
        private void DrawMvCheckUncheckAllSlidersVisButtons(bool forCaps, UnityEngine.Object undoRecordObject)
        {
            EditorGUILayout.BeginHorizontal();
            var content = new GUIContent();

            content.text    = "Show all";
            content.tooltip = "Show all " + (forCaps ? "caps." : "sliders.");
            if (GUILayout.Button(content, GUILayout.Width(80.0f)))
            {
                EditorUndoEx.Record(undoRecordObject);
                var visFlags = forCaps ? _mvSglSliderCapVis : _mvSglSliderVis;
                for (int index = 0; index < visFlags.Length; ++index)
                {
                    visFlags[index] = true;
                }
            }

            content.text    = "Hide all";
            content.tooltip = "Hide all " + (forCaps ? "caps." : "sliders.");
            if (GUILayout.Button(content, GUILayout.Width(80.0f)))
            {
                EditorUndoEx.Record(undoRecordObject);
                var visFlags = forCaps ? _mvSglSliderCapVis : _mvSglSliderVis;
                for (int index = 0; index < visFlags.Length; ++index)
                {
                    visFlags[index] = false;
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Example #4
0
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            float newFloat;

            var content = new GUIContent();

            content.text    = "X rotation step";
            content.tooltip = "The amount of rotation applied around the X axis.";
            newFloat        = EditorGUILayout.FloatField(content, XRotationStep);
            if (newFloat != XRotationStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                XRotationStep = newFloat;
            }

            content.text    = "Y rotation step";
            content.tooltip = "The amount of rotation applied around the Y axis.";
            newFloat        = EditorGUILayout.FloatField(content, YRotationStep);
            if (newFloat != YRotationStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                YRotationStep = newFloat;
            }

            content.text    = "Z rotation step";
            content.tooltip = "The amount of rotation applied around the Z axis.";
            newFloat        = EditorGUILayout.FloatField(content, ZRotationStep);
            if (newFloat != ZRotationStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                ZRotationStep = newFloat;
            }
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            float newFloat;

            EditorGUILayout.BeginVertical();

            // Switch mode
            GUIContent content = new GUIContent();

            content.text    = "Switch mode";
            content.tooltip = "Allows you to control the way in which a camera projection switch is performed.";
            CameraProjectionSwitchMode newSwitchMode = (CameraProjectionSwitchMode)EditorGUILayout.EnumPopup(content, SwitchMode);

            if (newSwitchMode != SwitchMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SwitchMode = newSwitchMode;
            }

            if (SwitchMode == CameraProjectionSwitchMode.Transition)
            {
                content.text    = "Duration (in seconds)";
                content.tooltip = "Allows you to specify the duration of the projection transition in seconds.";
                newFloat        = EditorGUILayout.FloatField(content, TransitionDurationInSeconds);
                if (newFloat != TransitionDurationInSeconds)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    TransitionDurationInSeconds = newFloat;
                }
            }

            EditorGUILayout.EndVertical();
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            int newInt; bool newBool;

            var content = new GUIContent();

            content.text    = "Can snap to grid";
            content.tooltip = "When turned on, vertices can be snapped to grid cells.";
            newBool         = EditorGUILayout.ToggleLeft(content, CanSnapToGrid);
            if (newBool != CanSnapToGrid)
            {
                EditorUndoEx.Record(undoRecordObject);
                CanSnapToGrid = newBool;
            }

            content.text    = "Can snap to object verts";
            content.tooltip = "When turned on, vertices can be snapped to other object vertices.";
            newBool         = EditorGUILayout.ToggleLeft(content, CanSnapToObjectVerts);
            if (newBool != CanSnapToObjectVerts)
            {
                EditorUndoEx.Record(undoRecordObject);
                CanSnapToObjectVerts = newBool;
            }

            content.text    = "Snap destination layers";
            content.tooltip = "Allows you to specify which layers can be used as snap destinations when doing vertex snapping.";
            newInt          = EditorGUILayoutEx.LayerMaskField(content, SnapDestinationLayers);
            if (newInt != SnapDestinationLayers)
            {
                EditorUndoEx.Record(undoRecordObject);
                SnapDestinationLayers = newInt;
            }
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            Color newColor; bool newBool;

            // Grid line color
            var content = new GUIContent();

            content.text    = "Line color";
            content.tooltip = "Allows you to control the color of the grid lines.";
            newColor        = EditorGUILayout.ColorField(content, LineColor);
            if (newColor != LineColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                LineColor = newColor;
            }

            // Cell fading
            content.text    = "Use cell fading";
            content.tooltip = "If this is true, the grid cells will fade in/out based on the distance between the camera and the grid. This " +
                              "is conistent with how Unity renders the scene grid inside the Editor.";
            newBool = EditorGUILayout.ToggleLeft(content, UseCellFading);
            if (newBool != UseCellFading)
            {
                EditorUndoEx.Record(undoRecordObject);
                UseCellFading = newBool;
            }
        }
Example #8
0
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            ScenePhysicsMode newPhysicsMode; float newFloat;
            var content = new GUIContent();

            content.text    = "Physics mode";
            content.tooltip = "Controls the way in which raycasts, overlap tests etc are performed. It is recommended to leave this to \'RLD\'. Otherwise, some " +
                              "plugin features might not work as expected (e.g. object 2 object snap, selection grab).";
            newPhysicsMode = (ScenePhysicsMode)EditorGUILayout.EnumPopup(content, PhysicsMode);
            if (newPhysicsMode != PhysicsMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                PhysicsMode = newPhysicsMode;
            }

            content.text    = "Non-mesh object size";
            content.tooltip = "This field is used to define the volume size of the objects that do not have a mesh (e.g. lights, particle systems etc). This size is " +
                              "needed to allow the system to perform raycasts or overlap tests for such objects.";
            newFloat = EditorGUILayout.FloatField(content, NonMeshObjectSize);
            if (newFloat != NonMeshObjectSize)
            {
                EditorUndoEx.Record(undoRecordObject);
                NonMeshObjectSize = newFloat;
            }
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            float newFloat;

            EditorGUILayout.BeginVertical();

            // Switch mode
            GUIContent content = new GUIContent();

            content.text    = "Switch mode";
            content.tooltip = "Allows you to control the way in which a rotation switch is performed.";
            CameraRotationSwitchMode newSwitchMode = (CameraRotationSwitchMode)EditorGUILayout.EnumPopup(content, SwitchMode);

            if (newSwitchMode != SwitchMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SwitchMode = newSwitchMode;
            }

            content.text    = "Switch type";
            content.tooltip = "Allows you to control the type of rotation switch.";
            CameraRotationSwitchType newSwitchType = (CameraRotationSwitchType)EditorGUILayout.EnumPopup(content, SwitchType);

            if (newSwitchType != SwitchType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SwitchType = newSwitchType;
            }

            // Constant switch mode settings
            if (SwitchMode == CameraRotationSwitchMode.Constant)
            {
                content.text    = "~Duration (in seconds)";
                content.tooltip = "The amount of time in seconds it takes the rotation switch to complete. This value is an approximation.";
                newFloat        = EditorGUILayout.FloatField(content, ConstantSwitchDurationInSeconds);
                if (newFloat != ConstantSwitchDurationInSeconds)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    ConstantSwitchDurationInSeconds = newFloat;
                }
            }
            else
            // Smooth switch mode settings
            if (SwitchMode == CameraRotationSwitchMode.Smooth)
            {
                // Smooth value
                content.text    = "Smooth value";
                content.tooltip = "The smooth value used to adjust the switch speed over time. The bigger the value, the faster " +
                                  "the target rotation is reached.";
                newFloat = EditorGUILayout.FloatField(content, SmoothValue);
                if (newFloat != SmoothValue)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SmoothValue = newFloat;
                }
            }

            EditorGUILayout.EndVertical();
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            float newFloat;

            EditorGUILayoutEx.SectionHeader("Hover epsilon");
            var content = new GUIContent();

            content.text    = "Line slider";
            content.tooltip = "Controls the precision used when hovering line sliders.";
            newFloat        = EditorGUILayout.FloatField(content, LineSliderHoverEps);
            if (newFloat != LineSliderHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetLineSliderHoverEps(newFloat);
            }

            content.text    = "Box slider";
            content.tooltip = "Controls the precision used when hovering box sliders.";
            newFloat        = EditorGUILayout.FloatField(content, BoxSliderHoverEps);
            if (newFloat != BoxSliderHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetBoxSliderHoverEps(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Snapping");
            content.text    = "X";
            content.tooltip = "Snap step value used when moving along the X axis.";
            newFloat        = EditorGUILayout.FloatField(content, XSnapStep);
            if (newFloat != XSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetXSnapStep(newFloat);
            }

            content.text    = "Y";
            content.tooltip = "Snap step value used when moving along the Y axis.";
            newFloat        = EditorGUILayout.FloatField(content, YSnapStep);
            if (newFloat != YSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetYSnapStep(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Drag sensitivity");
            content.text    = "Sensitivity";
            content.tooltip = "This value allows you to scale the slider drag speed.";
            newFloat        = EditorGUILayout.FloatField(content, DragSensitivity);
            if (newFloat != DragSensitivity)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetDragSensitivity(newFloat);
            }
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            float           newFloat;
            CameraFocusMode newFocusMode;

            // Focus mode
            var content = new GUIContent();

            content.text    = "Focus mode";
            content.tooltip = "Allows you to control the focus mode.";
            newFocusMode    = (CameraFocusMode)EditorGUILayout.EnumPopup(content, FocusMode);
            if (newFocusMode != FocusMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                FocusMode = newFocusMode;
            }

            // Distance add
            content.text    = "Focus distance add";
            content.tooltip = "When a camera is focused, it will be placed at some distance away from the focus target. " +
                              "This value can be used to increase this distance if needed. It can not take on negative values.";
            newFloat = EditorGUILayout.FloatField(content, FocusDistanceAdd);
            if (newFloat != FocusDistanceAdd)
            {
                EditorUndoEx.Record(undoRecordObject);
                FocusDistanceAdd = newFloat;
            }

            // Constant speed
            if (FocusMode == CameraFocusMode.Constant)
            {
                content.text    = "Speed (units/sec)";
                content.tooltip = "Allows you to control the speed at which the camera is focused.";
                newFloat        = EditorGUILayout.FloatField(content, ConstantSpeed);
                if (newFloat != ConstantSpeed)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    ConstantSpeed = newFloat;
                }
            }
            else
            // Smooth duration
            if (FocusMode == CameraFocusMode.Smooth)
            {
                content.text    = "Smooth time (seconds)";
                content.tooltip = "Allows you to control the duration of the smooth focus.";
                newFloat        = EditorGUILayout.FloatField(content, SmoothTime);
                if (newFloat != SmoothTime)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SmoothTime = newFloat;
                }
            }
        }
        public override void OnInspectorGUI()
        {
            Camera newCamera;

            var content = new GUIContent();

            content.text    = "Target camera";
            content.tooltip = "Allows you to specify the camera object which will be controlled by the RTFocusCamera script. Note: Prefabs are not allowed. Only scene cameras can be used.";
            newCamera       = EditorGUILayout.ObjectField(content, _camera.TargetCamera, typeof(Camera), true) as Camera;
            if (newCamera != _camera.TargetCamera)
            {
                EditorUndoEx.Record(_camera);
                _camera.SetTargetCamera(newCamera);
            }

            _camera.Settings.RenderEditorGUI(_camera);

            EditorGUILayout.Separator();
            _camera.MoveSettings.UsesFoldout  = true;
            _camera.MoveSettings.FoldoutLabel = "Move settings";
            _camera.MoveSettings.RenderEditorGUI(_camera);

            _camera.PanSettings.UsesFoldout  = true;
            _camera.PanSettings.FoldoutLabel = "Pan settings";
            _camera.PanSettings.RenderEditorGUI(_camera);

            _camera.LookAroundSettings.UsesFoldout  = true;
            _camera.LookAroundSettings.FoldoutLabel = "Look around settings";
            _camera.LookAroundSettings.RenderEditorGUI(_camera);

            _camera.OrbitSettings.UsesFoldout  = true;
            _camera.OrbitSettings.FoldoutLabel = "Orbit settings";
            _camera.OrbitSettings.RenderEditorGUI(_camera);

            _camera.ZoomSettings.UsesFoldout  = true;
            _camera.ZoomSettings.FoldoutLabel = "Zoom settings";
            _camera.ZoomSettings.RenderEditorGUI(_camera);

            _camera.FocusSettings.UsesFoldout  = true;
            _camera.FocusSettings.FoldoutLabel = "Focus settings";
            _camera.FocusSettings.RenderEditorGUI(_camera);

            _camera.RotationSwitchSettings.UsesFoldout  = true;
            _camera.RotationSwitchSettings.FoldoutLabel = "Rotation switch settings";
            _camera.RotationSwitchSettings.RenderEditorGUI(_camera);

            _camera.ProjectionSwitchSettings.UsesFoldout  = true;
            _camera.ProjectionSwitchSettings.FoldoutLabel = "Projection switch settings";
            _camera.ProjectionSwitchSettings.RenderEditorGUI(_camera);

            _camera.Hotkeys.UsesFoldout  = true;
            _camera.Hotkeys.FoldoutLabel = "Hotkeys";
            _camera.Hotkeys.RenderEditorGUI(_camera);
        }
Example #13
0
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            float newFloat; bool newBool; Color newColor;

            if (IsVisible)
            {
                EditorGUILayout.HelpBox("When the camera background is visible, it will obscure all sprites in the scene. This is an unfortunate side-effect of making " +
                                        "the camera background behave correctly in scenarios such as camera transform change and multiple viewports.", MessageType.Warning);
            }

            // Toggle visibility
            var content = new GUIContent();

            content.text    = "Is visible";
            content.tooltip = "Allows you to toggle the visibility of the camera background.";
            newBool         = EditorGUILayout.ToggleLeft(content, IsVisible);
            if (newBool != IsVisible)
            {
                EditorUndoEx.Record(undoRecordObject);
                IsVisible = newBool;
            }

            // First and second colors
            content.text    = "First color";
            content.tooltip = "Allows you to control the first color in the gradient.";
            newColor        = EditorGUILayout.ColorField(content, FirstColor);
            if (newColor != FirstColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                FirstColor = newColor;
            }

            content.text    = "Second color";
            content.tooltip = "Allows you to control the second color in the gradient.";
            newColor        = EditorGUILayout.ColorField(content, SecondColor);
            if (newColor != SecondColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SecondColor = newColor;
            }

            // Gradient offset
            content.text    = "Gradient offset";
            content.tooltip = "Allows you to control the gradient offset. Possible values are in the [-1, 1] interval. " +
                              "A value of -1 will render only the first color. A value of 1 will render only the second color.";
            newFloat = EditorGUILayout.Slider(content, GradientOffset, -1.0f, 1.0f);
            if (newFloat != GradientOffset)
            {
                EditorUndoEx.Record(undoRecordObject);
                GradientOffset = newFloat;
            }
        }
Example #14
0
        public void RenderEditorGUI(UnityEngine.Object undoRecordObject)
        {
            var content = new GUIContent();

            for (int tabIndex = 0; tabIndex < _tabs.Length; ++tabIndex)
            {
                if (tabIndex % _numTabsPerRow == 0)
                {
                    if (tabIndex == 0)
                    {
                        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
                    }
                    else
                    {
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                    }
                }

                content.text    = _tabs[tabIndex].Text;
                content.tooltip = _tabs[tabIndex].Tooltip;

                if (tabIndex == _activeTabIndex)
                {
                    GUIEx.PushColor(_activeTabColor);
                }
                else
                {
                    GUIEx.PushColor(Color.white);
                }
                if (GUILayout.Button(content, EditorStyles.toolbarButton))
                {
                    EditorUndoEx.Record(undoRecordObject);
                    _activeTabIndex = tabIndex;
                }
                GUIEx.PopColor();
            }
            EditorGUILayout.EndHorizontal();

            EditorToolbarTab activeTab = ActiveTab;

            if (activeTab.NumTargetSettings != 0)
            {
                activeTab.RenderTargetSettingsEditorGUI(undoRecordObject);
            }
            else
            if (activeTab.TargetToolbar != null)
            {
                activeTab.TargetToolbar.RenderEditorGUI(undoRecordObject);
            }
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            int newInt;

            var content = new GUIContent();

            content.text    = "Transformable layers";
            content.tooltip = "Allows you to specify which layers can be transformed by the gizmo. Objects which do not belong to a transformable layer will not be transformed by the gizmo.";
            newInt          = EditorGUILayoutEx.LayerMaskField(content, TransformableLayers);
            if (newInt != TransformableLayers)
            {
                EditorUndoEx.Record(undoRecordObject);
                TransformableLayers = newInt;
            }
        }
Example #16
0
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            bool newBool;

            var content = new GUIContent();

            content.text    = "Enable gizmo sorting";
            content.tooltip = "If this is checked, the gizmos wil be sorted by their distance from the camera so that they can be rendered in back to front order.";
            newBool         = EditorGUILayout.ToggleLeft(content, EnableGizmoSorting);
            if (newBool != EnableGizmoSorting)
            {
                EditorUndoEx.Record(undoRecordObject);
                EnableGizmoSorting = newBool;
            }
        }
Example #17
0
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            bool newBool;

            var content = new GUIContent();

            content.text    = "Can process input";
            content.tooltip = "Allows you to toggle input handling. You will usually want to turn this off when you have " +
                              "your own camera class that handles user input. Note: Turning this off will disable all actions " +
                              "that can be performed with the camera (zoom, pan, rotate, focus etc).";
            newBool = EditorGUILayout.ToggleLeft(content, CanProcessInput);
            if (newBool != CanProcessInput)
            {
                EditorUndoEx.Record(undoRecordObject);
                CanProcessInput = newBool;
            }
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            ScenePhysicsMode newPhysicsMode;
            var content = new GUIContent();

            content.text    = "Physics mode";
            content.tooltip = "Controls the way in which raycasts, overlap tests etc are performed. It is recommended to leave this to \'RTG\'. Otherwise, some " +
                              "plugin features might not work as expected (e.g. vertex snapping for the move gizmo). You should select \'UnityColliders\' if you " +
                              "are experiencing slow frame rates which can happen for heavily populated scenes. In that case, you will need to attach colliders for " +
                              "all objects that you would like to interact with.";
            newPhysicsMode = (ScenePhysicsMode)EditorGUILayout.EnumPopup(content, PhysicsMode);
            if (newPhysicsMode != PhysicsMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                PhysicsMode = newPhysicsMode;
            }
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            Vector3 newVector3;

            // No-volume object size
            var content = new GUIContent();

            content.text    = "No-volume object size";
            content.tooltip = "The custom interaction system needs to know the size of objects that have no volume. This defines a volume for these objects in the 3D world so that they " +
                              "can still be involved in raycasts, overlap tests etc";
            newVector3 = EditorGUILayout.Vector3Field(content, NoVolumeObjectSize);
            if (newVector3 != NoVolumeObjectSize)
            {
                EditorUndoEx.Record(undoRecordObject);
                NoVolumeObjectSize = newVector3;
            }
        }
Example #20
0
        private void DrawMvSliderCapVisibilityControls(AxisSign axisSign, UnityEngine.Object undoRecordObject)
        {
            var content = new GUIContent();

            EditorGUILayout.BeginHorizontal();
            string[] sliderLabels = axisSign == AxisSign.Positive ? new string[] { "+X", "+Y" } : new string[] { "-X", "-Y" };
            for (int sliderIndex = 0; sliderIndex < 2; ++sliderIndex)
            {
                content.text    = sliderLabels[sliderIndex];
                content.tooltip = "Toggle visibility for the " + sliderLabels[sliderIndex] + " cap.";

                bool isVisible = IsMvSliderCapVisible(sliderIndex, axisSign);
                bool newBool   = EditorGUILayout.ToggleLeft(content, isVisible, GUILayout.Width(60.0f));
                if (newBool != isVisible)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMvSliderCapVisible(sliderIndex, axisSign, newBool);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Example #21
0
        private void DrawDblSliderVisibilityControls(UnityEngine.Object undoRecordObject)
        {
            var content = new GUIContent();

            EditorGUILayout.BeginHorizontal();
            string[] sliderLabels = new string[] { "XY", "YZ", "ZX" };
            for (int sliderIndex = 0; sliderIndex < 3; ++sliderIndex)
            {
                content.text    = sliderLabels[sliderIndex];
                content.tooltip = "Toggle visibility for the " + sliderLabels[sliderIndex] + " double-axis slider.";

                bool isVisible = IsDblSliderVisible((PlaneId)sliderIndex);
                bool newBool   = EditorGUILayout.ToggleLeft(content, isVisible, GUILayout.Width(60.0f));
                if (newBool != isVisible)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetDblSliderVisible((PlaneId)sliderIndex, newBool);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            float                    newFloat; bool newBool; Color newColor; int newInt;
            GizmoShadeMode           newShadeMode;
            GizmoCircle3DBorderType  newCircleBorderType;
            GizmoFillMode3D          newFillMode3D;
            GizmoPolygon2DBorderType newPolyBorder2DType;

            EditorGUILayoutEx.SectionHeader("Scale and size");
            var content = new GUIContent();

            content.text    = "Use zoom factor";
            content.tooltip = "If this is checked, the gizmo will maintain a constant size regardless of its distance from the camera.";
            newBool         = EditorGUILayout.ToggleLeft(content, UseZoomFactor);
            if (newBool != UseZoomFactor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetUseZoomFactor(newBool);
            }

            content.text    = "Scale";
            content.tooltip = "The gizmo 3D scale. This is useful when you need to make the gizmo bigger or smaller because it maintains the relationship between different size properties.";
            newFloat        = EditorGUILayout.FloatField(content, Scale);
            if (newFloat != Scale)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScale(newFloat);
            }

            content.text    = "Radius";
            content.tooltip = "The radius of the rotation sphere. The final radius of the gizmo is actually: radius * scale * zoomFactor (if \'Use zoom factor\' is true).";
            newFloat        = EditorGUILayout.FloatField(content, Radius);
            if (newFloat != Radius)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRadius(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Slider border");
            content.text        = "Axis border type";
            content.tooltip     = "The type of shape that is used to draw the axis slider borders.";
            newCircleBorderType = (GizmoCircle3DBorderType)EditorGUILayout.EnumPopup(content, AxisBorderType);
            if (newCircleBorderType != AxisBorderType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisBorderType(newCircleBorderType);
            }

            if (AxisBorderType == GizmoCircle3DBorderType.Torus)
            {
                content.text    = "Torus thickness";
                content.tooltip = "The torus thickness for the axis sliders when the border type is set to \'Torus\'.";
                newFloat        = EditorGUILayout.FloatField(content, AxisTorusThickness);
                if (newFloat != AxisTorusThickness)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetAxisTorusThickness(newFloat);
                }
            }
            else
            if (AxisBorderType == GizmoCircle3DBorderType.CylindricalTorus)
            {
                content.text    = "Torus width";
                content.tooltip = "The torus width for the axis sliders when the border type is set to \'CylindricalTorus\'. The width extends inside the area of the circle.";
                newFloat        = EditorGUILayout.FloatField(content, AxisCylTorusWidth);
                if (newFloat != AxisCylTorusWidth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetAxisCylTorusWidth(newFloat);
                }

                content.text    = "Torus height";
                content.tooltip = "The torus height for the axis sliders when the border type is set to \'CylindricalTorus\'. The height is perpendicular to the circle area.";
                newFloat        = EditorGUILayout.FloatField(content, AxisCylTorusHeight);
                if (newFloat != AxisCylTorusHeight)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetAxisCylTorusHeight(newFloat);
                }
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Colors");
            content.text    = "X border";
            content.tooltip = "The border color of the X axis slider.";
            newColor        = EditorGUILayout.ColorField(content, XBorderColor);
            if (newColor != XBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisBorderColor(0, newColor);
            }

            content.text    = "Y border";
            content.tooltip = "The border color of the Y axis slider.";
            newColor        = EditorGUILayout.ColorField(content, YBorderColor);
            if (newColor != YBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisBorderColor(1, newColor);
            }

            content.text    = "Z border";
            content.tooltip = "The border color of the Z axis slider.";
            newColor        = EditorGUILayout.ColorField(content, ZBorderColor);
            if (newColor != ZBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisBorderColor(2, newColor);
            }

            content.text    = "Hovered";
            content.tooltip = "The hovered color.";
            newColor        = EditorGUILayout.ColorField(content, HoveredColor);
            if (newColor != HoveredColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetHoveredColor(newColor);
            }

            content.text    = "Mid cap";
            content.tooltip = "The color of middle cap.";
            newColor        = EditorGUILayout.ColorField(content, MidCapColor);
            if (newColor != MidCapColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMidCapColor(newColor);
            }

            content.text    = "Hovered mid cap";
            content.tooltip = "The middle cap hovered color.";
            newColor        = EditorGUILayout.ColorField(content, HoveredMidCapColor);
            if (newColor != HoveredMidCapColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetHoveredMidCapColor(newColor);
            }

            content.text    = "Axis border cull alpha scale";
            content.tooltip = "Allows you to specify an alpha scale value for the axis border pixels which are hidden behind the mid cap.";
            newFloat        = EditorGUILayout.FloatField(content, AxisCullAlphaScale);
            if (newFloat != AxisCullAlphaScale)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisBorderCullAlphaScale(newFloat);
            }

            content.text    = "Shade mode";
            content.tooltip = "The type of shading that is applied to the gizmo handles.";
            newShadeMode    = (GizmoShadeMode)EditorGUILayout.EnumPopup(content, ShadeMode);
            if (newShadeMode != ShadeMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetShadeMode(newShadeMode);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Fill");
            content.text    = "Axis border";
            content.tooltip = "Fill mode for the axes borders.";
            newFillMode3D   = (GizmoFillMode3D)EditorGUILayout.EnumPopup(content, AxisBorderFillMode);
            if (newFillMode3D != AxisBorderFillMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisBorderFillMode(newFillMode3D);
            }

            if (AxisBorderFillMode == GizmoFillMode3D.Wire)
            {
                content.text    = "Num torus axial slices";
                content.tooltip = "If a torus axis border is used, this is the number of axial slices used for wireframe rendering.";
                newInt          = EditorGUILayout.IntField(content, NumAxisTorusWireAxialSlices);
                if (newInt != NumAxisTorusWireAxialSlices)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetNumAxisTorusWireAxialSlices(newInt);
                }
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Rotation arc");
            content.text    = "Is visible";
            content.tooltip = "If this is checked, a rotation arc will appear during rotation. This does not apply to rotations performed with the mid cap.";
            newBool         = EditorGUILayout.ToggleLeft(content, IsRotationArcVisible);
            if (newBool != IsRotationArcVisible)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRotationArcVisible(newBool);
            }

            content.text    = "Fill color";
            content.tooltip = "The rotation arc fill color.";
            newColor        = EditorGUILayout.ColorField(content, RotationArcColor);
            if (newColor != RotationArcColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRotationArcColor(newColor);
            }

            content.text    = "Border color";
            content.tooltip = "The rotation arc border color.";
            newColor        = EditorGUILayout.ColorField(content, RotationArcBorderColor);
            if (newColor != RotationArcBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRotationArcBorderColor(newColor);
            }

            content.text    = "Use shortest arc";
            content.tooltip = "If this is checked, the rotation arc will never exceed 180 degrees and it will always choose the shortest rotation angle.";
            newBool         = EditorGUILayout.ToggleLeft(content, UseShortestRotationArc);
            if (newBool != UseShortestRotationArc)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetUseShortestRotationArc(newBool);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Camera look slider");
            content.text        = "Border type";
            content.tooltip     = "The type of border which is used to draw the circle that rotates around the camera look axis.";
            newPolyBorder2DType = (GizmoPolygon2DBorderType)EditorGUILayout.EnumPopup(content, CamLookSliderPolyBorderType);
            if (newPolyBorder2DType != CamLookSliderPolyBorderType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetCamLookSliderPolyBorderType(newPolyBorder2DType);
            }

            if (CamLookSliderPolyBorderType == GizmoPolygon2DBorderType.Thick)
            {
                content.text    = "Border thickness";
                content.tooltip = "When a thick border is used, this property represents the border thickness.";
                newFloat        = EditorGUILayout.FloatField(content, CamLookSliderPolyBorderThickness);
                if (newFloat != CamLookSliderPolyBorderThickness)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetCamLookSliderPolyBorderThickness(newFloat);
                }
            }

            content.text    = "Radius offset";
            content.tooltip = "This value is added to the \'Radius\' property to calculate the radius of the circle which can be used to rotate around the camera look axis.";
            newFloat        = EditorGUILayout.FloatField(content, CamLookSliderRadiusOffset);
            if (newFloat != CamLookSliderRadiusOffset)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetCamLookSliderRadiusOffset(newFloat);
            }

            content.text    = "Border color";
            content.tooltip = "The border color for the circle which can be used to rotate around the camera look axis.";
            newColor        = EditorGUILayout.ColorField(content, CamLookSliderBorderColor);
            if (newColor != CamLookSliderBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetCamLookSliderBorderColor(newColor);
            }

            content.text    = "Border hovered color";
            content.tooltip = "The hovered border color for the circle which can be used to rotate around the camera look axis.";
            newColor        = EditorGUILayout.ColorField(content, CamLookSliderHoveredBorderColor);
            if (newColor != CamLookSliderHoveredBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetCamLookSliderHoveredBorderColor(newColor);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Visibility");
            content.text    = "X axis";
            content.tooltip = "Controls the visibility of the X axis rotation slider.";
            newBool         = EditorGUILayout.ToggleLeft(content, IsAxisVisible(0));
            if (newBool != IsAxisVisible(0))
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisVisible(0, newBool);
            }

            content.text    = "Y axis";
            content.tooltip = "Controls the visibility of the Y axis rotation slider.";
            newBool         = EditorGUILayout.ToggleLeft(content, IsAxisVisible(1));
            if (newBool != IsAxisVisible(1))
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisVisible(1, newBool);
            }

            content.text    = "Z axis";
            content.tooltip = "Controls the visibility of the Z axis rotation slider.";
            newBool         = EditorGUILayout.ToggleLeft(content, IsAxisVisible(2));
            if (newBool != IsAxisVisible(2))
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisVisible(2, newBool);
            }

            content.text    = "Camera look slider";
            content.tooltip = "Controls the visibility of the circle slider which can be used to rotate aroudn the camera look vector.";
            newBool         = EditorGUILayout.ToggleLeft(content, IsCamLookSliderVisible);
            if (newBool != IsCamLookSliderVisible)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetCamLookSliderVisible(newBool);
            }

            content.text    = "Mid cap";
            content.tooltip = "Controls the visibility of the mid cap.";
            newBool         = EditorGUILayout.ToggleLeft(content, IsMidCapVisible);
            if (newBool != IsMidCapVisible)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMidCapVisible(newBool);
            }

            content.text    = "Mid cap border";
            content.tooltip = "Controls the visibility of the mid cap border.";
            newBool         = EditorGUILayout.ToggleLeft(content, IsMidCapBorderVisible);
            if (newBool != IsMidCapBorderVisible)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMidCapBorderVisible(newBool);
            }
        }
        private void RenderScaleContent(UnityEngine.Object undoRecordObject)
        {
            float newFloat;

            EditorGUILayoutEx.SectionHeader("Hover epsilon");
            var content = new GUIContent();

            content.text    = "Line slider";
            content.tooltip = "Controls the precision used when hovering line sliders.";
            newFloat        = EditorGUILayout.FloatField(content, ScLineSliderHoverEps);
            if (newFloat != ScLineSliderHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScLineSliderHoverEps(newFloat);
            }

            content.text    = "Box slider";
            content.tooltip = "Controls the precision used when hovering box sliders.";
            newFloat        = EditorGUILayout.FloatField(content, ScBoxSliderHoverEps);
            if (newFloat != ScBoxSliderHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScBoxSliderHoverEps(newFloat);
            }

            content.text    = "Cylinder slider";
            content.tooltip = "Controls the precision used when hovering cylinder sliders.";
            newFloat        = EditorGUILayout.FloatField(content, ScCylinderSliderHoverEps);
            if (newFloat != ScCylinderSliderHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScCylinderSliderHoverEps(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Snapping");
            content.text    = "X";
            content.tooltip = "The snap step for the X axis.";
            newFloat        = EditorGUILayout.FloatField(content, ScXSnapStep);
            if (newFloat != ScXSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScXSnapStep(newFloat);
            }

            content.text    = "Y";
            content.tooltip = "The snap step for the Y axis.";
            newFloat        = EditorGUILayout.FloatField(content, ScYSnapStep);
            if (newFloat != ScYSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScYSnapStep(newFloat);
            }

            content.text    = "Z";
            content.tooltip = "The snap step for the Z axis.";
            newFloat        = EditorGUILayout.FloatField(content, ScZSnapStep);
            if (newFloat != ScZSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScZSnapStep(newFloat);
            }

            content.text    = "XY";
            content.tooltip = "The snap step for the XY double-axis slider.";
            newFloat        = EditorGUILayout.FloatField(content, ScXYSnapStep);
            if (newFloat != ScXYSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScXYSnapStep(newFloat);
            }

            content.text    = "YZ";
            content.tooltip = "The snap step for the YZ double-axis slider.";
            newFloat        = EditorGUILayout.FloatField(content, ScYZSnapStep);
            if (newFloat != ScYZSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScYZSnapStep(newFloat);
            }

            content.text    = "ZX";
            content.tooltip = "The snap step for the ZX double-axis slider.";
            newFloat        = EditorGUILayout.FloatField(content, ScZXSnapStep);
            if (newFloat != ScZXSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScZXSnapStep(newFloat);
            }

            content.text    = "Uniform";
            content.tooltip = "The snap step value used for uniform scaling.";
            newFloat        = EditorGUILayout.FloatField(content, ScUniformSnapStep);
            if (newFloat != ScUniformSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScUniformScaleSnapStep(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Drag sensitivity");
            content.text    = "Sensitivity";
            content.tooltip = "This value allows you to scale the slider drag speed.";
            newFloat        = EditorGUILayout.FloatField(content, ScDragSensitivity);
            if (newFloat != ScDragSensitivity)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScDragSensitivity(newFloat);
            }
        }
        private void RenderRotateContent(UnityEngine.Object undoRecordObject)
        {
            float         newFloat; bool newBool;
            GizmoSnapMode newSnapMode;

            EditorGUILayoutEx.SectionHeader("Hover epsilon/misc");
            var content = new GUIContent();

            content.text    = "Axis line eps";
            content.tooltip = "Controls the precision used when hovering the axes rotation circles.";
            newFloat        = EditorGUILayout.FloatField(content, RtAxisLineHoverEps);
            if (newFloat != RtAxisLineHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtAxisLineHoverEps(newFloat);
            }

            content.text    = "Axis torus eps";
            content.tooltip = "Controls the precision used when hovering the axes rotation tori.";
            newFloat        = EditorGUILayout.FloatField(content, RtAxisTorusHoverEps);
            if (newFloat != RtAxisTorusHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtAxisTorusHoverEps(newFloat);
            }

            content.text    = "Cam look line eps";
            content.tooltip = "Controls the precision used when hovering the THIN border of the circle that rotates around the camera look axis.";
            newFloat        = EditorGUILayout.FloatField(content, RtCamLookLineHoverEps);
            if (newFloat != RtCamLookLineHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtCamLookLineHoverEps(newFloat);
            }

            content.text    = "Cam look thick eps";
            content.tooltip = "Controls the precision used when hovering the THICK border of the circle that rotates around the camera look axis.";
            newFloat        = EditorGUILayout.FloatField(content, RtCamLookThickHoverEps);
            if (newFloat != RtCamLookThickHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtCamLookThickHoverEps(newFloat);
            }

            content.text    = "Can hover culled pixels";
            content.tooltip = "If this is checked, you will be able to hover the culled areas/pixels (i.e. the pixels hiden behind the rotation sphere) of the axes sliders.";
            newBool         = EditorGUILayout.ToggleLeft(content, RtCanHoverCulledPixels);
            if (newBool != RtCanHoverCulledPixels)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtCanHoverCulledPixels(newBool);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Snapping");
            content.text    = "Snap mode";
            content.tooltip = "The rotation snap mode. Relative rotation counts from the current rotation angle. Absolute rotation counts from 0.";
            newSnapMode     = (GizmoSnapMode)EditorGUILayout.EnumPopup(content, RtSnapMode);
            if (newSnapMode != RtSnapMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtSnapMode(newSnapMode);
            }

            content.text    = "X";
            content.tooltip = "Snap step value used when rotating around the X axis.";
            newFloat        = EditorGUILayout.FloatField(content, RtXSnapStep);
            if (newFloat != RtXSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtAxisSnapStep(0, newFloat);
            }

            content.text    = "Y";
            content.tooltip = "Snap step value used when rotating around the Y axis.";
            newFloat        = EditorGUILayout.FloatField(content, RtYSnapStep);
            if (newFloat != RtYSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtAxisSnapStep(1, newFloat);
            }

            content.text    = "Z";
            content.tooltip = "Snap step value used when rotating around the Z axis.";
            newFloat        = EditorGUILayout.FloatField(content, RtZSnapStep);
            if (newFloat != RtZSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtAxisSnapStep(2, newFloat);
            }

            content.text    = "Camera right";
            content.tooltip = "Snap step value used when rotating around the camera right axis.";
            newFloat        = EditorGUILayout.FloatField(content, RtCamRightSnapStep);
            if (newFloat != RtCamRightSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtCamRightSnapStep(newFloat);
            }

            content.text    = "Camera up";
            content.tooltip = "Snap step value used when rotating around the camera up axis.";
            newFloat        = EditorGUILayout.FloatField(content, RtCamUpSnapStep);
            if (newFloat != RtCamUpSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtCamUpSnapStep(newFloat);
            }

            content.text    = "Camera look";
            content.tooltip = "Snap step value used when rotating around the camera look axis.";
            newFloat        = EditorGUILayout.FloatField(content, RtCamLookSnapStep);
            if (newFloat != RtCamLookSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtCamLookSnapStep(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Drag sensitivity");
            content.text    = "Sensitivity";
            content.tooltip = "This value allows you to scale the slider drag speed.";
            newFloat        = EditorGUILayout.FloatField(content, RtDragSensitivity);
            if (newFloat != RtDragSensitivity)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetRtDragSensitivity(newFloat);
            }
        }
        private void RenderMoveContent(UnityEngine.Object undoRecordObject)
        {
            float newFloat;

            EditorGUILayoutEx.SectionHeader("Hover epsilon");
            var content = new GUIContent();

            content.text    = "Line slider";
            content.tooltip = "Controls the precision used when hovering line sliders.";
            newFloat        = EditorGUILayout.FloatField(content, MvLineSliderHoverEps);
            if (newFloat != MvLineSliderHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvLineSliderHoverEps(newFloat);
            }

            content.text    = "Box slider";
            content.tooltip = "Controls the precision used when hovering box sliders.";
            newFloat        = EditorGUILayout.FloatField(content, MvBoxSliderHoverEps);
            if (newFloat != MvBoxSliderHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvBoxSliderHoverEps(newFloat);
            }

            content.text    = "Cylinder slider";
            content.tooltip = "Controls the precision used when hovering cylinder sliders.";
            newFloat        = EditorGUILayout.FloatField(content, MvCylinderSliderHoverEps);
            if (newFloat != MvCylinderSliderHoverEps)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvCylinderSliderHoverEps(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Snapping");
            content.text    = "X";
            content.tooltip = "Allows you to specify the snap step for the X axis.";
            newFloat        = EditorGUILayout.FloatField(content, MvXSnapStep);
            if (newFloat != MvXSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvXSnapStep(newFloat);
            }

            content.text    = "Y";
            content.tooltip = "Allows you to specify the snap step for the Y axis.";
            newFloat        = EditorGUILayout.FloatField(content, MvYSnapStep);
            if (newFloat != MvYSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvYSnapStep(newFloat);
            }

            content.text    = "Z";
            content.tooltip = "Allows you to specify the snap step for the Z axis.";
            newFloat        = EditorGUILayout.FloatField(content, MvZSnapStep);
            if (newFloat != MvZSnapStep)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvZSnapStep(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Drag sensitivity");
            content.text    = "Sensitivity";
            content.tooltip = "This value allows you to scale the slider drag speed.";
            newFloat        = EditorGUILayout.FloatField(content, MvDragSensitivity);
            if (newFloat != MvDragSensitivity)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvDragSensitivity(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Vertex snapping");
            _mvVertexSnapSettings.RenderEditorGUI(undoRecordObject);
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            RTGizmosEngine gizmosEngine = RTGizmosEngine.Get;
            var            content      = new GUIContent();

            EditorGUILayout.BeginHorizontal();
            content.text    = "Inherit";
            content.tooltip = "Inherit different category of settings from the other gizmos (move, rotate or scale).";
            if (GUILayout.Button(content))
            {
                EditorUndoEx.Record(undoRecordObject);
                if (InheritCategory == UniversalGizmoSettingsCategory.Move)
                {
                    if (InheritType == UniversalGizmoSettingsType.Settings2D)
                    {
                        gizmosEngine.UniversalGizmoSettings2D.Inherit(gizmosEngine.MoveGizmoSettings2D);
                    }
                    else
                    if (InheritType == UniversalGizmoSettingsType.Settings3D)
                    {
                        gizmosEngine.UniversalGizmoSettings3D.Inherit(gizmosEngine.MoveGizmoSettings3D);
                    }
                    else
                    if (InheritType == UniversalGizmoSettingsType.LookAndFeel2D)
                    {
                        gizmosEngine.UniversalGizmoLookAndFeel2D.Inherit(gizmosEngine.MoveGizmoLookAndFeel2D);
                    }
                    else
                    if (InheritType == UniversalGizmoSettingsType.LookAndFeel3D)
                    {
                        gizmosEngine.UniversalGizmoLookAndFeel3D.Inherit(gizmosEngine.MoveGizmoLookAndFeel3D);
                    }
                }
                else
                if (InheritCategory == UniversalGizmoSettingsCategory.Rotate)
                {
                    if (InheritType == UniversalGizmoSettingsType.Settings3D)
                    {
                        gizmosEngine.UniversalGizmoSettings3D.Inherit(gizmosEngine.RotationGizmoSettings3D);
                    }
                    else
                    if (InheritType == UniversalGizmoSettingsType.LookAndFeel3D)
                    {
                        gizmosEngine.UniversalGizmoLookAndFeel3D.Inherit(gizmosEngine.RotationGizmoLookAndFeel3D);
                    }
                }
                else
                if (InheritCategory == UniversalGizmoSettingsCategory.Scale)
                {
                    if (InheritType == UniversalGizmoSettingsType.Settings3D)
                    {
                        gizmosEngine.UniversalGizmoSettings3D.Inherit(gizmosEngine.ScaleGizmoSettings3D);
                    }
                    else
                    if (InheritType == UniversalGizmoSettingsType.LookAndFeel3D)
                    {
                        gizmosEngine.UniversalGizmoLookAndFeel3D.Inherit(gizmosEngine.ScaleGizmoLookAndFeel3D);
                    }
                }
            }

            UniversalGizmoSettingsCategory newCategory;
            UniversalGizmoSettingsType     newInheritType;

            newCategory = (UniversalGizmoSettingsCategory)EditorGUILayout.EnumPopup(InheritCategory);
            if (newCategory != InheritCategory)
            {
                EditorUndoEx.Record(undoRecordObject);
                InheritCategory = newCategory;
            }
            newInheritType = (UniversalGizmoSettingsType)EditorGUILayout.EnumPopup(InheritType);
            if (newInheritType != InheritType)
            {
                EditorUndoEx.Record(undoRecordObject);
                InheritType = newInheritType;
            }
            EditorGUILayout.EndHorizontal();

            content.text    = "Display category";
            content.tooltip = "Specifies what category of settings are currently displayed for modification.";
            newCategory     = (UniversalGizmoSettingsCategory)EditorGUILayout.EnumPopup(content, DisplayCategory);
            if (newCategory != DisplayCategory)
            {
                EditorUndoEx.Record(undoRecordObject);
                DisplayCategory = newCategory;
            }

            gizmosEngine.UniversalGizmoSettings2D.DisplayCategory    = DisplayCategory;
            gizmosEngine.UniversalGizmoSettings3D.DisplayCategory    = DisplayCategory;
            gizmosEngine.UniversalGizmoLookAndFeel2D.DisplayCategory = DisplayCategory;
            gizmosEngine.UniversalGizmoLookAndFeel3D.DisplayCategory = DisplayCategory;

            gizmosEngine.UniversalGizmoSettings2D.CanBeDisplayed    = true;
            gizmosEngine.UniversalGizmoLookAndFeel2D.CanBeDisplayed = true;
            gizmosEngine.UniversalGizmoSettings3D.CanBeDisplayed    = true;
            gizmosEngine.UniversalGizmoLookAndFeel3D.CanBeDisplayed = true;

            if (DisplayCategory != UniversalGizmoSettingsCategory.Move)
            {
                gizmosEngine.UniversalGizmoSettings2D.CanBeDisplayed    = false;
                gizmosEngine.UniversalGizmoLookAndFeel2D.CanBeDisplayed = false;
            }
        }
Example #27
0
        private void RenderMoveContent(UnityEngine.Object undoRecordObject)
        {
            float            newFloat; Color newColor; bool newBool;
            GizmoLine2DType  newLine2DType;
            GizmoCap2DType   newCap2DType;
            GizmoFillMode2D  newFillMode2D;
            GizmoPlane2DType newPlane2DType;

            EditorGUILayoutEx.SectionHeader("Scale");
            var content = new GUIContent();

            content.text    = "Scale";
            content.tooltip = "The gizmo 2D scale. This is useful when you need to make the gizmo bigger or smaller because it maintains the relationship between different size properties.";
            newFloat        = EditorGUILayout.FloatField(content, MvScale);
            if (newFloat != MvScale)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvScale(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Slider shape");
            content.text    = "Slider type";
            content.tooltip = "The type of shape which is used to draw the single-axis sliders.";
            newLine2DType   = (GizmoLine2DType)EditorGUILayout.EnumPopup(content, MvSliderLineType);
            if (newLine2DType != MvSliderLineType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvSliderLineType(newLine2DType);
            }

            content.text    = "Slider length";
            content.tooltip = "The single-axis slider length.";
            newFloat        = EditorGUILayout.FloatField(content, MvSliderLength);
            if (newFloat != MvSliderLength)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvSliderLength(newFloat);
            }

            if (MvSliderLineType == GizmoLine2DType.Box)
            {
                content.text    = "Slider box thickness";
                content.tooltip = "The box thickness for single-axis sliders when the slider type is set to \'Box\'.";
                newFloat        = EditorGUILayout.FloatField(content, MvBoxSliderThickness);
                if (newFloat != MvBoxSliderThickness)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMvBoxSliderThickness(newFloat);
                }
            }

            content.text    = "Dbl slider type";
            content.tooltip = "The type of shape which is used to draw the double-axis slider.";
            newPlane2DType  = (GizmoPlane2DType)EditorGUILayout.EnumPopup(content, MvDblSliderPlaneType);
            if (newPlane2DType != MvDblSliderPlaneType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvDblSliderPlaneType(newPlane2DType);
            }

            if (MvDblSliderPlaneType == GizmoPlane2DType.Quad)
            {
                content.text    = "Quad width";
                content.tooltip = "The double-axis slider quad width when the dbl slider type is set to \'Quad\'.";
                newFloat        = EditorGUILayout.FloatField(content, MvDblSliderQuadWidth);
                if (newFloat != MvDblSliderQuadWidth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMvDblSliderQuadWidth(newFloat);
                }

                content.text    = "Quad height";
                content.tooltip = "The double-axis slider quad height when the dbl slider type is set to \'Quad\'.";
                newFloat        = EditorGUILayout.FloatField(content, MvDblSliderQuadHeight);
                if (newFloat != MvDblSliderQuadHeight)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMvDblSliderQuadHeight(newFloat);
                }
            }
            else
            if (MvDblSliderPlaneType == GizmoPlane2DType.Circle)
            {
                content.text    = "Circle radius";
                content.tooltip = "The double-axis slider circle radius when the dbl slider type is set to \'Circle\'.";
                newFloat        = EditorGUILayout.FloatField(content, MvDblSliderCircleRadius);
                if (newFloat != MvDblSliderCircleRadius)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMvDblSliderCircleRadius(newFloat);
                }
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Cap shape");
            content.text    = "Slider cap type";
            content.tooltip = "The type of shape which is used to draw the single-axis slidre caps.";
            newCap2DType    = (GizmoCap2DType)EditorGUILayout.EnumPopup(content, MvSliderCapType);
            if (newCap2DType != MvSliderCapType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvSliderCapType(newCap2DType);
            }

            if (MvSliderCapType == GizmoCap2DType.Arrow)
            {
                content.text    = "Arrow height";
                content.tooltip = "The arrow height for slider caps when the cap type is set to \'Arrow\'.";
                newFloat        = EditorGUILayout.FloatField(content, MvSliderArrowCapHeight);
                if (newFloat != MvSliderArrowCapHeight)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMvSliderArrowCapHeight(newFloat);
                }

                content.text    = "Arrow radius";
                content.tooltip = "The arrow radius for slider caps when the cap type is set to \'Arrow\'.";
                newFloat        = EditorGUILayout.FloatField(content, MvSliderArrowCapBaseRadius);
                if (newFloat != MvSliderArrowCapBaseRadius)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMvSliderArrowCapBaseRadius(newFloat);
                }
            }
            else
            if (MvSliderCapType == GizmoCap2DType.Quad)
            {
                content.text    = "Quad width";
                content.tooltip = "The quad width for slider caps when the cap type is set to \'Quad\'.";
                newFloat        = EditorGUILayout.FloatField(content, MvSliderQuadCapWidth);
                if (newFloat != MvSliderQuadCapWidth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMvSliderQuadCapWidth(newFloat);
                }

                content.text    = "Quad height";
                content.tooltip = "The quad height for slider caps when the cap type is set to \'Quad\'.";
                newFloat        = EditorGUILayout.FloatField(content, MvSliderQuadCapHeight);
                if (newFloat != MvSliderQuadCapHeight)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMvSliderQuadCapHeight(newFloat);
                }
            }
            else
            if (MvSliderCapType == GizmoCap2DType.Circle)
            {
                content.text    = "Circle radius";
                content.tooltip = "The circle radius for slider caps when the cap type is set to \'Circle\'.";
                newFloat        = EditorGUILayout.FloatField(content, MvSliderCircleCapRadius);
                if (newFloat != MvSliderCircleCapRadius)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMvSliderCircleCapRadius(newFloat);
                }
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Colors");
            content.text    = "X fill";
            content.tooltip = "The X axis fill color. Applies to the X axis slider and its cap.";
            newColor        = EditorGUILayout.ColorField(content, MvXColor);
            if (newColor != MvXColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvAxisColor(0, newColor);
            }

            content.text    = "X border";
            content.tooltip = "The X axis border color. Applies to the X axis slider and its cap.";
            newColor        = EditorGUILayout.ColorField(content, MvXBorderColor);
            if (newColor != MvXBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvAxisBorderColor(0, newColor);
            }

            content.text    = "Y fill";
            content.tooltip = "The Y axis fill color. Applies to the Y axis slider and its cap.";
            newColor        = EditorGUILayout.ColorField(content, MvYColor);
            if (newColor != MvYColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvAxisColor(1, newColor);
            }

            content.text    = "Y border";
            content.tooltip = "The Y axis border color. Applies to the Y axis slider and its cap.";
            newColor        = EditorGUILayout.ColorField(content, MvYBorderColor);
            if (newColor != MvYBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvAxisBorderColor(1, newColor);
            }

            content.text    = "Hovered fill";
            content.tooltip = "The hovered fill color. Applies to single sliders and their caps only. The double slider has its own color properties.";
            newColor        = EditorGUILayout.ColorField(content, MvSliderHoveredColor);
            if (newColor != MvSliderHoveredColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvSliderHoveredFillColor(newColor);
            }

            content.text    = "Hovered border";
            content.tooltip = "The hovered border color. Applies to single sliders and their caps only. The double slider has its own color properties.";
            newColor        = EditorGUILayout.ColorField(content, MvSliderHoveredBorderColor);
            if (newColor != MvSliderHoveredBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvSliderHoveredBorderColor(newColor);
            }

            EditorGUILayout.Separator();
            content.text    = "Dbl slider fill";
            content.tooltip = "The double-axis slider fill color.";
            newColor        = EditorGUILayout.ColorField(content, MvDblSliderColor);
            if (newColor != MvDblSliderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvDblSliderColor(newColor);
            }

            content.text    = "Dbl slider border";
            content.tooltip = "The double-axis slider border color.";
            newColor        = EditorGUILayout.ColorField(content, MvDblSliderBorderColor);
            if (newColor != MvDblSliderBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvDblSliderBorderColor(newColor);
            }

            content.text    = "Hovered dbl slider fill";
            content.tooltip = "The fill color of the double-axis slider when it is hovered.";
            newColor        = EditorGUILayout.ColorField(content, MvDblSliderHoveredColor);
            if (newColor != MvDblSliderHoveredColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvDblSliderHoveredColor(newColor);
            }

            content.text    = "Hovered dbl slider border";
            content.tooltip = "The border color of the double-axis slider when it is hovered.";
            newColor        = EditorGUILayout.ColorField(content, MvDblSliderHoveredBorderColor);
            if (newColor != MvDblSliderHoveredBorderColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvDblSliderHoveredBorderColor(newColor);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Fill");
            content.text    = "Sliders";
            content.tooltip = "The fill mode for single-axis sliders. Does not affet caps. Caps have their own fill property.";
            newFillMode2D   = (GizmoFillMode2D)EditorGUILayout.EnumPopup(content, MvSliderFillMode);
            if (newFillMode2D != MvSliderFillMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvSliderFillMode(newFillMode2D);
            }

            content.text    = "Caps";
            content.tooltip = "The fill mode for single-axis slider caps.";
            newFillMode2D   = (GizmoFillMode2D)EditorGUILayout.EnumPopup(content, MvSliderCapFillMode);
            if (newFillMode2D != MvSliderCapFillMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvSliderCapFillMode(newFillMode2D);
            }

            content.text    = "Dbl slider";
            content.tooltip = "The double-slider fill mode.";
            newFillMode2D   = (GizmoFillMode2D)EditorGUILayout.EnumPopup(content, MvDblSliderFillMode);
            if (newFillMode2D != MvDblSliderFillMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvDblSliderFillMode(newFillMode2D);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Slider visibility");
            DrawMvSliderVisibilityControls(AxisSign.Positive, undoRecordObject);
            DrawMvSliderVisibilityControls(AxisSign.Negative, undoRecordObject);
            DrawMvCheckUncheckAllSlidersVisButtons(false, undoRecordObject);

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Slider cap visibility");
            DrawMvSliderCapVisibilityControls(AxisSign.Positive, undoRecordObject);
            DrawMvSliderCapVisibilityControls(AxisSign.Negative, undoRecordObject);
            DrawMvCheckUncheckAllSlidersVisButtons(true, undoRecordObject);

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Dbl slider visibility");
            content.text    = "Is visible";
            content.tooltip = "Controls the visiblity of the double slider.";
            newBool         = EditorGUILayout.ToggleLeft(content, IsMvDblSliderVisible);
            if (newBool != IsMvDblSliderVisible)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMvDblSliderVisible(newBool);
            }
        }
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            bool           newBool; Color newColor; Vector2 newVec2; float newFloat;
            GizmoShadeMode newShadeMode; SceneGizmoScreenCorner newScreenCorner;
            GizmoCap3DType newCapType;

            EditorGUILayoutEx.SectionHeader("Placement");
            var content = new GUIContent();

            content.text    = "Screen corner";
            content.tooltip = "Allows you to specify the screen corner in which the gizmo will be rendered.";
            newScreenCorner = (SceneGizmoScreenCorner)EditorGUILayout.EnumPopup(content, ScreenCorner);
            if (newScreenCorner != ScreenCorner)
            {
                EditorUndoEx.Record(undoRecordObject);
                ScreenCorner = newScreenCorner;
            }

            content.text    = "Screen offset";
            content.tooltip = "Allows you to apply an offset to the scene gizmo in screen space to change the location of where the gizmo is drawn on the screen.";
            newVec2         = EditorGUILayout.Vector2Field(content, ScreenOffset);
            if (newVec2 != ScreenOffset)
            {
                EditorUndoEx.Record(undoRecordObject);
                ScreenOffset = newVec2;
            }

            content.text    = "Screen size";
            content.tooltip = "Allows you to change the gizmo screen size.";
            newFloat        = EditorGUILayout.FloatField(content, ScreenSize);
            if (newFloat != ScreenSize)
            {
                EditorUndoEx.Record(undoRecordObject);
                ScreenSize = newFloat;
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Shapes");
            content.text    = "Axes caps";
            content.tooltip = "Allows you to change the shape of the axes caps.";
            newCapType      = (GizmoCap3DType)EditorGUILayoutEx.SelectiveEnumPopup(content, AxisCapLookAndFeel.CapType, GetAllowedAxesCapTypes());
            if (newCapType != AxisCapLookAndFeel.CapType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisCapType(newCapType);
            }

            content.text    = "Mid cap";
            content.tooltip = "Allows you to change the shape of the middle cap.";
            newCapType      = (GizmoCap3DType)EditorGUILayoutEx.SelectiveEnumPopup(content, _midCapLookAndFeel.CapType, GetAllowedMidCapTypes());
            if (newCapType != _midCapLookAndFeel.CapType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMidCapType(newCapType);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Shading");
            content.text    = "Axes caps";
            content.tooltip = "The type of shading that is applied to the axes caps.";
            newShadeMode    = (GizmoShadeMode)EditorGUILayout.EnumPopup(content, AxisCapLookAndFeel.ShadeMode);
            if (newShadeMode != AxisCapLookAndFeel.ShadeMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetAxisCapShadeMode(newShadeMode);
            }

            content.text    = "Mid cap";
            content.tooltip = "The type of shading that is applied to the middle cap.";
            newShadeMode    = (GizmoShadeMode)EditorGUILayout.EnumPopup(content, _midCapLookAndFeel.ShadeMode);
            if (newShadeMode != _midCapLookAndFeel.ShadeMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMidCapShadeMode(newShadeMode);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Colors");
            string[]   axesCapLabels = new string[] { "Positive X", "Positive Y", "Positive Z", "Negative X", "Negative Y", "Negative Z" };
            int[]      axesIndices   = new int[] { 0, 1, 2, 0, 1, 2 };
            AxisSign[] axesSigns     = new AxisSign[] { AxisSign.Positive, AxisSign.Positive, AxisSign.Positive, AxisSign.Negative, AxisSign.Negative, AxisSign.Negative };
            for (int axisIndex = 0; axisIndex < 6; ++axisIndex)
            {
                content.text    = axesCapLabels[axisIndex];
                content.tooltip = "The color of the " + axesCapLabels[axisIndex].ToLower() + ".";

                var lookAndFeel = GetAxisCapLookAndFeel(axesIndices[axisIndex], axesSigns[axisIndex]);
                newColor = EditorGUILayout.ColorField(content, lookAndFeel.Color);
                if (newColor != lookAndFeel.Color)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetAxisCapColor(newColor, axesIndices[axisIndex], axesSigns[axisIndex]);
                }
            }

            content.text    = "Mid cap";
            content.tooltip = "Allows you to change the color of the mid cap.";
            newColor        = EditorGUILayout.ColorField(content, _midCapLookAndFeel.Color);
            if (newColor != _midCapLookAndFeel.Color)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMidCapColor(newColor);
            }

            content.text    = "Hovered color";
            content.tooltip = "Gizmo hovered color.";
            newColor        = EditorGUILayout.ColorField(content, AxisCapLookAndFeel.HoveredColor);
            if (newColor != AxisCapLookAndFeel.HoveredColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetHoveredColor(newColor);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Labels");
            EditorGUILayout.HelpBox("The alpha value of the axes labels is ignored. The alpha component will always have the same value as the corresponding axis.", MessageType.Info);
            content.text    = "Axes label tint";
            content.tooltip = "Allows you to change the color of the labels associated with the gizmo axes. Note: The alpha component is ignored. The alpha value will " +
                              "always be retrieved from the color of the associated axis.";
            newColor = EditorGUILayout.ColorField(content, AxesLabelTint);
            if (newColor != AxesLabelTint)
            {
                EditorUndoEx.Record(undoRecordObject);
                AxesLabelTint = newColor;
            }

            content.text    = "Cam prj switch label tint";
            content.tooltip = "Allows you to change the color of the label that is used to display the current camera projection type (perspective or ortho).";
            newColor        = EditorGUILayout.ColorField(content, CamPrjSwitchLabelTint);
            if (newColor != CamPrjSwitchLabelTint)
            {
                EditorUndoEx.Record(undoRecordObject);
                CamPrjSwitchLabelTint = newColor;
            }

            content.text    = "Show prj switch label";
            content.tooltip = "If this is checked, the gizmo will render a label which indicates the current camera projection type (perspective or ortho). " +
                              "This label can also be used to switch between the 2 camera projection modes.";
            newBool = EditorGUILayout.ToggleLeft(content, IsCamPrjSwitchLabelVisible);
            if (newBool != IsCamPrjSwitchLabelVisible)
            {
                EditorUndoEx.Record(undoRecordObject);
                IsCamPrjSwitchLabelVisible = newBool;
            }
        }
        public void RenderEditorGUI(UnityEngine.Object undoRecordObject)
        {
            bool        newBool;
            const float toggleWidth = 65.0f;

            // Shortcut name label
            EditorGUILayout.BeginVertical("Box");
            EditorGUILayoutEx.SectionHeader(Name);

            // Enabled/disabled
            var content = new GUIContent();

            content.text    = "Is enabled";
            content.tooltip = "Allows you to enable/disable a shortcut key.";
            newBool         = EditorGUILayout.ToggleLeft(content, IsEnabled);
            if (newBool != IsEnabled)
            {
                EditorUndoEx.Record(undoRecordObject);
                IsEnabled = newBool;
            }

            int selectedIndex = _availableKeyNames.IndexOf(Key.ToString());
            int newIndex      = EditorGUILayout.Popup("Key", selectedIndex, _availableKeyNames.ToArray());

            if (newIndex != selectedIndex)
            {
                EditorUndoEx.Record(undoRecordObject);
                Key = _availableKeys[newIndex];
            }

            // Modifiers
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical("Box");
            newBool = EditorGUILayout.ToggleLeft("LCtrl", _lCtrl, GUILayout.Width(toggleWidth));
            if (newBool != _lCtrl)
            {
                EditorUndoEx.Record(undoRecordObject);
                _lCtrl = newBool;
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Box");
            newBool = EditorGUILayout.ToggleLeft("LCmd", _lCmd, GUILayout.Width(toggleWidth));
            if (newBool != _lCmd)
            {
                EditorUndoEx.Record(undoRecordObject);
                _lCmd = newBool;
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Box");
            newBool = EditorGUILayout.ToggleLeft("LAlt", _lAlt, GUILayout.Width(toggleWidth));
            if (newBool != _lAlt)
            {
                EditorUndoEx.Record(undoRecordObject);
                _lAlt = newBool;
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Box");
            newBool = EditorGUILayout.ToggleLeft("LShift", _lShift, GUILayout.Width(toggleWidth));
            if (newBool != _lShift)
            {
                EditorUndoEx.Record(undoRecordObject);
                _lShift = newBool;
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            // Mouse buttons
            if (_staticData.CanHaveMouseButtons)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical("Box");
                newBool = EditorGUILayout.ToggleLeft("LMouse", _lMouseBtn, GUILayout.Width(toggleWidth));
                if (newBool != _lMouseBtn)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    _lMouseBtn = newBool;
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical("Box");
                newBool = EditorGUILayout.ToggleLeft("RMouse", _rMouseBtn, GUILayout.Width(toggleWidth));
                if (newBool != _rMouseBtn)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    _rMouseBtn = newBool;
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical("Box");
                newBool = EditorGUILayout.ToggleLeft("MMouse", _mMouseBtn, GUILayout.Width(toggleWidth));
                if (newBool != _mMouseBtn)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    _mMouseBtn = newBool;
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }
Example #30
0
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            float           newFloat; bool newBool; Color newColor;
            GizmoLine3DType newLineType;
            GizmoShadeMode  newShadeMode;
            GizmoFillMode3D newFillMode3D;
            GizmoCap3DType  newCap3DType;

            EditorGUILayoutEx.SectionHeader("Scale");
            var content = new GUIContent();

            content.text    = "Use zoom factor";
            content.tooltip = "If this is checked, the gizmo will maintain a constant size regardless of its distance from the camera.";
            newBool         = EditorGUILayout.ToggleLeft(content, UseZoomFactor);
            if (newBool != UseZoomFactor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetUseZoomFactor(newBool);
            }

            content.text    = "Scale";
            content.tooltip = "The gizmo 3D scale. This is useful when you need to make the gizmo bigger or smaller because it maintains the relationship between different size properties.";
            newFloat        = EditorGUILayout.FloatField(content, Scale);
            if (newFloat != Scale)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScale(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Slider shape");
            content.text    = "Slider type";
            content.tooltip = "The type of shape which is used to draw the single-axis sliders.";
            newLineType     = (GizmoLine3DType)EditorGUILayout.EnumPopup(content, SliderLineType);
            if (newLineType != SliderLineType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetSliderLineType(newLineType);
            }

            content.text    = "Slider length";
            content.tooltip = "The single-axis slider length.";
            newFloat        = EditorGUILayout.FloatField(content, SliderLength);
            if (newFloat != SliderLength)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetSliderLength(newFloat);
            }

            if (SliderLineType == GizmoLine3DType.Box)
            {
                content.text    = "Box height";
                content.tooltip = "The box height for single-axis sliders when the slider type is set to \'Box\'.";
                newFloat        = EditorGUILayout.FloatField(content, BoxSliderHeight);
                if (newFloat != BoxSliderHeight)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetBoxSliderHeight(newFloat);
                }

                content.text    = "Box depth";
                content.tooltip = "The box depth for single-axis sliders when the slider type is set to \'Box\'.";
                newFloat        = EditorGUILayout.FloatField(content, BoxSliderDepth);
                if (newFloat != BoxSliderDepth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetBoxSliderDepth(newFloat);
                }
            }
            else
            if (SliderLineType == GizmoLine3DType.Cylinder)
            {
                content.text    = "Cylinder radius";
                content.tooltip = "The cylinder radius for single-axis sliders when the slider type is set to \'Cylinder\'.";
                newFloat        = EditorGUILayout.FloatField(content, CylinderSliderRadius);
                if (newFloat != CylinderSliderRadius)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetCylinderSliderRadius(newFloat);
                }
            }

            content.text    = "Dbl slider size";
            content.tooltip = "The size of the double-axis sliders. Applies to both dimensions.";
            newFloat        = EditorGUILayout.FloatField(content, DblSliderSize);
            if (newFloat != DblSliderSize)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetDblSliderSize(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Cap shape");
            content.text    = "Slider cap type";
            content.tooltip = "The type of shape which is used to draw the single-axis slider caps.";
            newCap3DType    = (GizmoCap3DType)EditorGUILayout.EnumPopup(content, SliderCapType);
            if (newCap3DType != SliderCapType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetSliderCapType(newCap3DType);
            }

            if (SliderCapType == GizmoCap3DType.Box)
            {
                content.text    = "Box width";
                content.tooltip = "The box width for single-axis slider caps when the cap type is set to \'Box\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderBoxCapWidth);
                if (newFloat != SliderBoxCapWidth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderBoxCapWidth(newFloat);
                }

                content.text    = "Box height";
                content.tooltip = "The box height for single-axis slider caps when the cap type is set to \'Box\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderBoxCapHeight);
                if (newFloat != SliderBoxCapHeight)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderBoxCapHeight(newFloat);
                }

                content.text    = "Box depth";
                content.tooltip = "The box depth for single-axis slider caps when the cap type is set to \'Box\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderBoxCapDepth);
                if (newFloat != SliderBoxCapDepth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderBoxCapDepth(newFloat);
                }
            }
            else
            if (SliderCapType == GizmoCap3DType.Cone)
            {
                content.text    = "Cone height";
                content.tooltip = "The cone height for single-axis slider caps when the cap type is set to \'Cone\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderConeCapHeight);
                if (newFloat != SliderConeCapHeight)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderConeCapHeight(newFloat);
                }

                content.text    = "Cone radius";
                content.tooltip = "The cone radius for single-axis slider caps when the cap type is set to \'Cone\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderConeCapBaseRadius);
                if (newFloat != SliderConeCapBaseRadius)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderConeCapBaseRadius(newFloat);
                }
            }
            else
            if (SliderCapType == GizmoCap3DType.Pyramid)
            {
                content.text    = "Pyramid width";
                content.tooltip = "The pyramid width for single-axis slider caps when the cap type is set to \'Pyramid\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderPyramidCapWidth);
                if (newFloat != SliderPyramidCapWidth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderPyramidCapWidth(newFloat);
                }

                content.text    = "Pyramid height";
                content.tooltip = "The pyramid height for single-axis slider caps when the cap type is set to \'Pyramid\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderPyramidCapHeight);
                if (newFloat != SliderPyramidCapHeight)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderPyramidCapHeight(newFloat);
                }

                content.text    = "Pyramid depth";
                content.tooltip = "The pyramid depth for single-axis slider caps when the cap type is set to \'Pyramid\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderPyramidCapDepth);
                if (newFloat != SliderPyramidCapDepth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderPyramidCapDepth(newFloat);
                }
            }
            else
            if (SliderCapType == GizmoCap3DType.TriangPrism)
            {
                content.text    = "Triang prism width";
                content.tooltip = "The prism width for single-axis slider caps when the cap type is set to \'TriangPrism\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderTriPrismCapWidth);
                if (newFloat != SliderTriPrismCapWidth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderTriPrismCapWidth(newFloat);
                }

                content.text    = "Triang prism height";
                content.tooltip = "The prism height for single-axis slider caps when the cap type is set to \'TriangPrism\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderTriPrismCapHeight);
                if (newFloat != SliderTriPrismCapHeight)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderTriPrismCapHeight(newFloat);
                }

                content.text    = "Triang prism depth";
                content.tooltip = "The prism depth for single-axis slider caps when the cap type is set to \'TriangPrism\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderTriPrismCapDepth);
                if (newFloat != SliderTriPrismCapDepth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderTriPrismCapDepth(newFloat);
                }
            }
            else
            if (SliderCapType == GizmoCap3DType.Sphere)
            {
                content.text    = "Sphere radius";
                content.tooltip = "The sphere radius for single-axis slider caps when the cap type is set to \'Sphere\'.";
                newFloat        = EditorGUILayout.FloatField(content, SliderSphereCapRadius);
                if (newFloat != SliderSphereCapRadius)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetSliderSphereCapRadius(newFloat);
                }
            }

            content.text    = "Mid cap type";
            content.tooltip = "The type of shape which is used to draw the mid cap.";
            newCap3DType    = (GizmoCap3DType)EditorGUILayoutEx.SelectiveEnumPopup(content, MidCapType, GetAllowedMidCapTypes());
            if (newCap3DType != MidCapType)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMidCapType(newCap3DType);
            }

            if (MidCapType == GizmoCap3DType.Sphere)
            {
                content.text    = "Sphere radius";
                content.tooltip = "The mid cap sphere radius when the mid cap type is set to \'Sphere\'.";
                newFloat        = EditorGUILayout.FloatField(content, MidCapSphereRadius);
                if (newFloat != MidCapSphereRadius)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMidCapSphereRadius(newFloat);
                }
            }
            else
            if (MidCapType == GizmoCap3DType.Box)
            {
                content.text    = "Box width";
                content.tooltip = "The mid cap box width when the mid cap type is set to \'Box\'.";
                newFloat        = EditorGUILayout.FloatField(content, MidCapBoxWidth);
                if (newFloat != MidCapBoxWidth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMidCapBoxWidth(newFloat);
                }

                content.text    = "Box height";
                content.tooltip = "The mid cap box height when the mid cap type is set to \'Box\'.";
                newFloat        = EditorGUILayout.FloatField(content, MidCapBoxHeight);
                if (newFloat != MidCapBoxHeight)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMidCapBoxHeight(newFloat);
                }

                content.text    = "Box depth";
                content.tooltip = "The mid cap box depth when the mid cap type is set to \'Box\'.";
                newFloat        = EditorGUILayout.FloatField(content, MidCapBoxDepth);
                if (newFloat != MidCapBoxDepth)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetMidCapBoxDepth(newFloat);
                }
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Colors");
            string[] axesLabels = new string[] { "X", "Y", "Z" };
            for (int axisIndex = 0; axisIndex < 3; ++axisIndex)
            {
                GizmoLineSlider3DLookAndFeel sliderLookAndFeel = GetSglSliderLookAndFeel(axisIndex, AxisSign.Positive);

                content.text    = axesLabels[axisIndex];
                content.tooltip = "The color of the " + axesLabels[axisIndex] + " axis when it is not hovered.";
                newColor        = EditorGUILayout.ColorField(content, sliderLookAndFeel.Color);
                if (newColor != sliderLookAndFeel.Color)
                {
                    EditorUndoEx.Record(undoRecordObject);
                    SetAxisColor(axisIndex, newColor);
                }
            }

            content.text    = "Mid cap";
            content.tooltip = "The color of the mid cap.";
            newColor        = EditorGUILayout.ColorField(content, MidCapColor);
            if (newColor != MidCapColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMidCapColor(newColor);
            }

            content.text    = "Hovered";
            content.tooltip = "The gizmo hovered color.";
            newColor        = EditorGUILayout.ColorField(content, HoveredColor);
            if (newColor != HoveredColor)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetHoveredColor(newColor);
            }

            content.text    = "Dbl slider fill alpha";
            content.tooltip = "The alpha value used to draw the area of the double-axis sliders.";
            newFloat        = EditorGUILayout.FloatField(content, DblSliderFillAlpha);
            if (newFloat != DblSliderFillAlpha)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetDblSliderFillAlpha(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Shading");
            content.text    = "Sliders";
            content.tooltip = "The type of shading that is applied to single-axis sliders. Does not apply to caps. Caps have their own shade property.";
            newShadeMode    = (GizmoShadeMode)EditorGUILayout.EnumPopup(content, SliderShadeMode);
            if (newShadeMode != SliderShadeMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetSliderShadeMode(newShadeMode);
            }

            content.text    = "Slider caps";
            content.tooltip = "The type of shading that is applied to single-axis slider caps.";
            newShadeMode    = (GizmoShadeMode)EditorGUILayout.EnumPopup(content, SliderCapShadeMode);
            if (newShadeMode != SliderCapShadeMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetSliderCapShadeMode(newShadeMode);
            }

            content.text    = "Mid cap";
            content.tooltip = "The type of shading that is applied to the mid cap.";
            newShadeMode    = (GizmoShadeMode)EditorGUILayout.EnumPopup(content, MidCapShadeMode);
            if (newShadeMode != MidCapShadeMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMidCapShadeMode(newShadeMode);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Fill");
            content.text    = "Sliders";
            content.tooltip = "Fill mode for single-axis sliders. Does not apply to caps. Caps have their own fill property.";
            newFillMode3D   = (GizmoFillMode3D)EditorGUILayout.EnumPopup(content, SliderFillMode);
            if (newFillMode3D != SliderFillMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetSliderFillMode(newFillMode3D);
            }

            content.text    = "Slider caps";
            content.tooltip = "Fill mode for slider caps.";
            newFillMode3D   = (GizmoFillMode3D)EditorGUILayout.EnumPopup(content, SliderCapFillMode);
            if (newFillMode3D != SliderCapFillMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetSliderCapFillMode(newFillMode3D);
            }

            content.text    = "Mid cap";
            content.tooltip = "Fill mode for the mid cap.";
            newFillMode3D   = (GizmoFillMode3D)EditorGUILayout.EnumPopup(content, MidCapFillMode);
            if (newFillMode3D != MidCapFillMode)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetMidCapFillMode(newFillMode3D);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Scale guide");
            content.text    = "Is visible";
            content.tooltip = "If this is checked, the gizmo will draw a scale guide for each entity that is being scaled during a scale session. The guide is shown " +
                              "in the form of a collection of coordinate system axes.";
            newBool = EditorGUILayout.ToggleLeft(content, IsScaleGuideVisible);
            if (newBool != IsScaleGuideVisible)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScaleGuideVisible(newBool);
            }

            content.text    = "Axis length";
            content.tooltip = "If the scale guide is visible, this value is used to determine the length of the guide axes.";
            newFloat        = EditorGUILayout.FloatField(content, ScaleGuideAxisLength);
            if (newFloat != ScaleGuideAxisLength)
            {
                EditorUndoEx.Record(undoRecordObject);
                SetScaleGuideAxisLength(newFloat);
            }

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Slider visibility");
            DrawSliderVisibilityControls(AxisSign.Positive, undoRecordObject);
            DrawSliderVisibilityControls(AxisSign.Negative, undoRecordObject);
            DrawCheckUncheckAllSlidersVisButtons(false, undoRecordObject);

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Dbl slider visibility");
            DrawDblSliderVisibilityControls(undoRecordObject);
            DrawCheckUncheckAllDblSlidersVisButtons(undoRecordObject);

            EditorGUILayout.Separator();
            EditorGUILayoutEx.SectionHeader("Cap visibility");
            DrawSliderCapVisibilityControls(AxisSign.Positive, undoRecordObject);
            DrawSliderCapVisibilityControls(AxisSign.Negative, undoRecordObject);
            DrawCheckUncheckAllSlidersVisButtons(true, undoRecordObject);
        }