public override void OnInspectorGUI()
        {
            base.BeginProperties(showColor: false);

            // Color properties
            EditorGUILayout.PropertyField(propColorMode);
            switch ((Disc.DiscColorMode)propColorMode.enumValueIndex)
            {
            case Disc.DiscColorMode.Single:
                base.PropertyFieldColor();
                break;

            case Disc.DiscColorMode.Radial:
                base.PropertyFieldColor("Inner");
                EditorGUILayout.PropertyField(propColorOuterStart, new GUIContent("Outer"));
                break;

            case Disc.DiscColorMode.Angular:
                base.PropertyFieldColor("Start");
                EditorGUILayout.PropertyField(propColorInnerEnd, new GUIContent("End"));
                break;

            case Disc.DiscColorMode.Bilinear:
                base.PropertyFieldColor("Inner Start");
                EditorGUILayout.PropertyField(propColorOuterStart, new GUIContent("Outer Start"));
                EditorGUILayout.PropertyField(propColorInnerEnd, new GUIContent("Inner End"));
                EditorGUILayout.PropertyField(propColorOuterEnd, new GUIContent("Outer End"));
                break;
            }

            using (new EditorGUILayout.HorizontalScope()) {
                EditorGUILayout.PrefixLabel("Type");
                ShapesUI.DrawTypeSwitchButtons(propType, ShapesAssets.DiscTypeButtonContents, 20);
            }

            DiscType selectedType = (DiscType)propType.enumValueIndex;

            if (propType.enumValueIndex == (int)DiscType.Arc)
            {
                ShapesUI.EnumToggleProperty(propArcEndCaps, "Round Caps");
            }
            ShapesUI.FloatInSpaceField(propRadius, propRadiusSpace);
            using (new EditorGUI.DisabledScope(selectedType.HasThickness() == false && serializedObject.isEditingMultipleObjects == false))
                ShapesUI.FloatInSpaceField(propThickness, propThicknessSpace);
            DrawAngleProperties(selectedType);

            ShapesUI.BeginGroup();
            dashEditor.DrawProperties();
            ShapesUI.EndGroup();

            base.EndProperties();
        }
Example #2
0
        public override void OnInspectorGUI()
        {
            SerializedObject so = serializedObject;

            // show detail edit
            bool showDetailEdit = targets.OfType <Line>().Any(x => x.Geometry == LineGeometry.Volumetric3D);

            base.BeginProperties(showColor: false, canEditDetailLevel: showDetailEdit);

            bool updateGeometry = false;

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(propGeometry, new GUIContent("Geometry"));
            if (EditorGUI.EndChangeCheck())
            {
                updateGeometry = true;
            }
            EditorGUILayout.PropertyField(propStart);
            EditorGUILayout.PropertyField(propEnd);
            ShapesUI.FloatInSpaceField(propThickness, propThicknessSpace);
            scenePointEditor.GUIEditButton("Edit Points in Scene");

            // style (color, caps, dashes)
            ShapesUI.BeginGroup();
            EditorGUILayout.PropertyField(propColorMode);
            if ((Line.LineColorMode)propColorMode.enumValueIndex == Line.LineColorMode.Single)
            {
                base.PropertyFieldColor();
            }
            else
            {
                using (new EditorGUILayout.HorizontalScope()) {
                    EditorGUILayout.PrefixLabel("Colors");
                    base.PropertyFieldColor(GUIContent.none);
                    EditorGUILayout.PropertyField(propColorEnd, GUIContent.none);
                }
            }

            using (new EditorGUILayout.HorizontalScope()) {
                EditorGUILayout.PrefixLabel("End Caps");
                if (ShapesUI.DrawTypeSwitchButtons(propEndCaps, UIAssets.LineCapButtonContents))
                {
                    updateGeometry = true;
                }
            }

            ShapesUI.EndGroup();

            // Dashes
            ShapesUI.BeginGroup();
            dashEditor.DrawProperties();
            ShapesUI.EndGroup();

            base.EndProperties();

            if (updateGeometry)
            {
                foreach (Line line in targets.Cast <Line>())
                {
                    line.UpdateMesh();
                }
            }
        }
        protected void BeginProperties(bool showColor = true, bool canEditDetailLevel = true)
        {
            soRnd.Update();

            ShapesUI.BeginGroup();
            updateMeshFromEditorChange = false;

            ShapesUI.SortedEnumPopup <ShapesBlendMode>(blendModeGuiContent, propBlendMode);
            if ((target as ShapeRenderer).HasScaleModes)
            {
                EditorGUILayout.PropertyField(propScaleMode, scaleModeGuiContent);
            }

            // sorting/depth stuff
            using (new EditorGUI.IndentLevelScope(1)) {
                if (showDepth = EditorGUILayout.Foldout(showDepth, "Sorting & Depth"))
                {
                    using (ShapesUI.TempLabelWidth(140)) {
                        ShapesUI.RenderSortingLayerField(propSortingLayer);
                        EditorGUILayout.PropertyField(propSortingOrder);
                        EditorGUILayout.PropertyField(propZTest, zTestGuiContent);
                        EditorGUILayout.PropertyField(propZOffsetFactor, zOffsetFactorGuiContent);
                        EditorGUILayout.PropertyField(propZOffsetUnits, zOffsetUnitsGuiContent);
                    }
                }
            }

            // stencil
            using (new EditorGUI.IndentLevelScope(1)) {
                if (showStencil = EditorGUILayout.Foldout(showStencil, "Stencil Buffer"))
                {
                    EditorGUILayout.PropertyField(propStencilComp, stencilCompGuiContent);
                    EditorGUILayout.PropertyField(propStencilOpPass, stencilOpPassGuiContent);
                    EditorGUILayout.PropertyField(propStencilRefID, stencilIDGuiContent);
                    EditorGUILayout.PropertyField(propStencilReadMask, stencilReadMaskGuiContent);
                    EditorGUILayout.PropertyField(propStencilWriteMask, stencilWriteMaskGuiContent);
                }
            }

            // warning box about instancing
            int uniqueCount    = 0;
            int instancedCount = 0;

            foreach (ShapeRenderer obj in targets.Cast <ShapeRenderer>())
            {
                if (obj.IsUsingUniqueMaterials)
                {
                    uniqueCount++;
                }
                else
                {
                    instancedCount++;
                }
            }

            if (uniqueCount > 0)
            {
                string infix;
                if (instancedCount == 0)
                {
                    infix = uniqueCount == 1 ? "this object is" : "these objects are";
                }
                else                 // mixed selection
                {
                    infix = "some of these objects are";
                }

                string label = $"Note: {infix} not GPU instanced due to custom depth/stencil settings";

                GUIStyle wrapLabel = new GUIStyle(EditorStyles.miniLabel);
                wrapLabel.wordWrap = true;
                using (ShapesUI.Horizontal) {
                    GUIContent icon = EditorGUIUtility.IconContent("console.warnicon.sml");
                    GUILayout.Label(icon);
                    GUILayout.TextArea(label, wrapLabel);
                    if (GUILayout.Button("Reset", EditorStyles.miniButton))
                    {
                        propZTest.enumValueIndex         = (int)ShapeRenderer.DEFAULT_ZTEST;
                        propZOffsetFactor.floatValue     = ShapeRenderer.DEFAULT_ZOFS_FACTOR;
                        propZOffsetUnits.intValue        = ShapeRenderer.DEFAULT_ZOFS_UNITS;
                        propStencilComp.enumValueIndex   = (int)ShapeRenderer.DEFAULT_STENCIL_COMP;
                        propStencilOpPass.enumValueIndex = (int)ShapeRenderer.DEFAULT_STENCIL_OP;
                        propStencilRefID.intValue        = ShapeRenderer.DEFAULT_STENCIL_REF_ID;
                        propStencilReadMask.intValue     = ShapeRenderer.DEFAULT_STENCIL_MASK;
                        propStencilWriteMask.intValue    = ShapeRenderer.DEFAULT_STENCIL_MASK;
                    }
                }
            }

            ShapesUI.EndGroup();

            if ((target as ShapeRenderer).HasDetailLevels)
            {
                using (new EditorGUI.DisabledScope(canEditDetailLevel == false)) {
                    if (canEditDetailLevel)
                    {
                        using (var chChk = new EditorGUI.ChangeCheckScope()) {
                            EditorGUILayout.PropertyField(propDetailLevel);
                            if (chChk.changed)
                            {
                                updateMeshFromEditorChange = true;
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.TextField(propDetailLevel.displayName, "∞", GUI.skin.label);
                    }
                }
            }

            if (showColor)
            {
                PropertyFieldColor();
            }
        }
        protected void BeginProperties(bool showColor = true)
        {
            soRnd.Update();


            ShapesUI.BeginGroup();
            using (ShapesUI.Horizontal) {
                using (ShapesUI.TempFieldWidth(180f))
                    ShapesUI.RenderSortingLayerField(propSortingLayer);
                using (ShapesUI.TempLabelWidth(40f))
                    EditorGUILayout.PropertyField(propSortingOrder, new GUIContent("Order"));
            }

            EditorGUILayout.PropertyField(propZTest, zTestGuiContent);
            EditorGUILayout.PropertyField(propZOffsetFactor, zOffsetFactorGuiContent);
            EditorGUILayout.PropertyField(propZOffsetUnits, zOffsetUnitsGuiContent);

            // todo: add little warning box about instancing
            int uniqueCount    = 0;
            int instancedCount = 0;

            foreach (ShapeRenderer obj in targets.Cast <ShapeRenderer>())
            {
                if (obj.IsUsingUniqueMaterials)
                {
                    uniqueCount++;
                }
                else
                {
                    instancedCount++;
                }
            }

            if (uniqueCount > 0)
            {
                string label;
                if (instancedCount == 0)
                {
                    if (uniqueCount == 1)                      // single non-instanced
                    {
                        label = "Note: this object is not GPU instanced due to custom depth settings";
                    }
                    else                     // multiple exclusively non-instanced
                    {
                        label = "Note: these objects are not GPU instanced due to custom depth settings";
                    }
                }
                else                   // mixed selection
                {
                    label = "Note: some of these objects are not GPU instanced due to custom depth settings";
                }

                GUIStyle wrapLabel = new GUIStyle(EditorStyles.miniLabel);
                wrapLabel.wordWrap = true;
                using (ShapesUI.Horizontal) {
                    GUIContent icon = EditorGUIUtility.IconContent("console.warnicon.sml");
                    GUILayout.Label(icon);
                    GUILayout.TextArea(label, wrapLabel);
                }
            }

            ShapesUI.EndGroup();

            EditorGUILayout.PropertyField(propBlendMode, blendModeGuiContent);
            if ((target as ShapeRenderer).HasScaleModes)
            {
                EditorGUILayout.PropertyField(propScaleMode, scaleModeGuiContent);
            }
            if (showColor)
            {
                PropertyFieldColor();
            }
        }
Example #5
0
        public override void OnInspectorGUI()
        {
            SerializedObject so = serializedObject;

            base.BeginProperties(showColor: false);

            bool updateGeometry = false;

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(propGeometry, new GUIContent("Geometry"));
            if (EditorGUI.EndChangeCheck())
            {
                updateGeometry = true;
            }

            // shape (positions & thickness)
            ShapesUI.BeginGroup();
            EditorGUILayout.PropertyField(propStart);
            EditorGUILayout.PropertyField(propEnd);
            ShapesUI.FloatInSpaceField(propThickness, propThicknessSpace);
            ShapesUI.EndGroup();

            // style (color, caps, dashes)
            ShapesUI.BeginGroup();
            EditorGUILayout.PropertyField(propColorMode);
            if ((Line.LineColorMode)propColorMode.enumValueIndex == Line.LineColorMode.Single)
            {
                base.PropertyFieldColor();
            }
            else
            {
                using (new EditorGUILayout.HorizontalScope()) {
                    EditorGUILayout.PrefixLabel("Colors");
                    base.PropertyFieldColor(GUIContent.none);
                    EditorGUILayout.PropertyField(propColorEnd, GUIContent.none);
                }
            }

            using (new EditorGUILayout.HorizontalScope()) {
                EditorGUILayout.PrefixLabel("End Caps");
                if (ShapesUI.DrawTypeSwitchButtons(propEndCaps, ShapesAssets.LineCapButtonContents, 20))
                {
                    updateGeometry = true;
                }
            }

            ShapesUI.EndGroup();

            // Dashes
            ShapesUI.BeginGroup();
            dashEditor.DrawProperties();
            ShapesUI.EndGroup();

            base.EndProperties();

            if (updateGeometry)
            {
                foreach (Line line in targets.Cast <Line>())
                {
                    line.UpdateMesh();
                }
            }
        }
Example #6
0
        public override void OnInspectorGUI()
        {
            base.BeginProperties(showColor: false);

            EditorGUILayout.PropertyField(propGeometry);

            // Color properties
            EditorGUILayout.PropertyField(propColorMode);
            switch ((Disc.DiscColorMode)propColorMode.enumValueIndex)
            {
            case Disc.DiscColorMode.Single:
                base.PropertyFieldColor();
                break;

            case Disc.DiscColorMode.Radial:
                base.PropertyFieldColor("Inner");
                EditorGUILayout.PropertyField(propColorOuterStart, new GUIContent("Outer"));
                break;

            case Disc.DiscColorMode.Angular:
                base.PropertyFieldColor("Start");
                EditorGUILayout.PropertyField(propColorInnerEnd, new GUIContent("End"));
                break;

            case Disc.DiscColorMode.Bilinear:
                base.PropertyFieldColor("Inner Start");
                EditorGUILayout.PropertyField(propColorOuterStart, new GUIContent("Outer Start"));
                EditorGUILayout.PropertyField(propColorInnerEnd, new GUIContent("Inner End"));
                EditorGUILayout.PropertyField(propColorOuterEnd, new GUIContent("Outer End"));
                break;
            }

            using (new EditorGUILayout.HorizontalScope()) {
                EditorGUILayout.PrefixLabel("Type");
                ShapesUI.DrawTypeSwitchButtons(propType, UIAssets.DiscTypeButtonContents);
            }

            DiscType selectedType = (DiscType)propType.enumValueIndex;

            if (propType.enumValueIndex == (int)DiscType.Arc)
            {
                ShapesUI.EnumToggleProperty(propArcEndCaps, "Round Caps");
            }
            ShapesUI.FloatInSpaceField(propRadius, propRadiusSpace);
            using (new EditorGUI.DisabledScope(selectedType.HasThickness() == false && serializedObject.isEditingMultipleObjects == false))
                ShapesUI.FloatInSpaceField(propThickness, propThicknessSpace);
            DrawAngleProperties(selectedType);

            bool canEditInSceneView = propRadiusSpace.hasMultipleDifferentValues || propRadiusSpace.enumValueIndex == (int)ThicknessSpace.Meters;

            using (new EditorGUI.DisabledScope(canEditInSceneView == false))
                discEditor.GUIEditButton();

            bool hasDashablesInSelection = targets.Any(x => (x as Disc).HasThickness);

            ShapesUI.BeginGroup();
            using (new EditorGUI.DisabledScope(hasDashablesInSelection == false))
                dashEditor.DrawProperties();
            ShapesUI.EndGroup();

            base.EndProperties();
        }