public SceneGizmoLookAndFeel()
        {
            for (int axisIndex = 0; axisIndex < _axesCapsLookAndFeel.Length; ++axisIndex)
            {
                _axesCapsLookAndFeel[axisIndex] = new GizmoCap3DLookAndFeel();
            }

            SetMidCapColor(RTSystemValues.CenterAxisColor);
            SetMidCapType(GizmoCap3DType.Box);

            SetAxisCapColor(RTSystemValues.XAxisColor, 0, AxisSign.Positive);
            SetAxisCapColor(RTSystemValues.YAxisColor, 1, AxisSign.Positive);
            SetAxisCapColor(RTSystemValues.ZAxisColor, 2, AxisSign.Positive);
            SetAxisCapColor(RTSystemValues.CenterAxisColor, 0, AxisSign.Negative);
            SetAxisCapColor(RTSystemValues.CenterAxisColor, 1, AxisSign.Negative);
            SetAxisCapColor(RTSystemValues.CenterAxisColor, 2, AxisSign.Negative);
            SetAxisCapType(GizmoCap3DType.Cone);

            OnScreenSizeChanged();
        }
Exemplo n.º 2
0
        public SceneGizmoLookAndFeel()
        {
            for (int axisIndex = 0; axisIndex < _axesCapsLookAndFeel.Length; ++axisIndex)
            {
                _axesCapsLookAndFeel[axisIndex] = new GizmoCap3DLookAndFeel();
            }

            SetMidCapColor(RTSystemValues.CenterAxisColor);
            SetMidCapType(GizmoCap3DType.Box);

            SetAxisCapColor(RTSystemValues.XAxisColor, 0, AxisSign.Positive);
            SetAxisCapColor(RTSystemValues.YAxisColor, 1, AxisSign.Positive);
            SetAxisCapColor(RTSystemValues.ZAxisColor, 2, AxisSign.Positive);
            SetAxisCapColor(RTSystemValues.CenterAxisColor, 0, AxisSign.Negative);
            SetAxisCapColor(RTSystemValues.CenterAxisColor, 1, AxisSign.Negative);
            SetAxisCapColor(RTSystemValues.CenterAxisColor, 2, AxisSign.Negative);
            SetAxisCapType(GizmoCap3DType.Cone);

            _midCapLookAndFeel.BoxWidth     = MidCapBoxSize;
            _midCapLookAndFeel.BoxHeight    = MidCapBoxSize;
            _midCapLookAndFeel.BoxDepth     = MidCapBoxSize;
            _midCapLookAndFeel.SphereRadius = MidCapSphereRadius;
        }
Exemplo n.º 3
0
        protected override void RenderContent(UnityEngine.Object undoRecordObject)
        {
            bool           newBool; Color newColor; Vector2 newVec2; float newFloat;
            GizmoShadeMode newShadeMode; SceneGizmoScreenCorner newScreenCorner;
            GizmoCap3DType newCapType;

            EditorGUILayoutEx.SectionHeader("Placement");
            GUIContent 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() + ".";

                GizmoCap3DLookAndFeel 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;
            }
        }