Пример #1
0
        public ScaleGizmoLookAndFeel3D()
        {
            for (int axisIndex = 0; axisIndex < _sglSlidersLookAndFeel.Length; ++axisIndex)
            {
                _sglSlidersLookAndFeel[axisIndex] = new GizmoLineSlider3DLookAndFeel();
            }

            for (int axisIndex = 0; axisIndex < _dblSlidersLookAndFeel.Length; ++axisIndex)
            {
                _dblSlidersLookAndFeel[axisIndex]           = new GizmoPlaneSlider3DLookAndFeel();
                _dblSlidersLookAndFeel[axisIndex].PlaneType = GizmoPlane3DType.RATriangle;
            }

            SetSliderCapType(GizmoCap3DType.Box);
            SetSliderLength(5.5f);

            SetAxisColor(0, RTSystemValues.XAxisColor);
            SetAxisColor(1, RTSystemValues.YAxisColor);
            SetAxisColor(2, RTSystemValues.ZAxisColor);
            SetHoveredColor(RTSystemValues.HoveredAxisColor);

            SetSliderVisible(0, AxisSign.Positive, true);
            SetSliderCapVisible(0, AxisSign.Positive, true);
            SetSliderVisible(1, AxisSign.Positive, true);
            SetSliderCapVisible(1, AxisSign.Positive, true);
            SetSliderVisible(2, AxisSign.Positive, true);
            SetSliderCapVisible(2, AxisSign.Positive, true);

            SetMidCapColor(RTSystemValues.CenterAxisColor);
            SetMidCapType(GizmoCap3DType.Box);
            SetMidCapBoxWidth(0.9f);
            SetMidCapBoxHeight(0.9f);
            SetMidCapBoxDepth(0.9f);
            SetMidCapSphereRadius(0.65f);

            SetDblSliderFillAlpha(RTSystemValues.AxisAlpha);
            SetDblSliderSize(1.9f);
            SetDblSliderVisible(PlaneId.XY, true);
            SetDblSliderVisible(PlaneId.YZ, true);
            SetDblSliderVisible(PlaneId.ZX, true);
        }
Пример #2
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);
        }