public override void OnInspectorGUI()
        {
            serializedObject.Update();
            base.BeginProperties();
            bool multiEditing = serializedObject.isEditingMultipleObjects;

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

            EditorGUILayout.PropertyField(propPivot);
            using (new EditorGUILayout.HorizontalScope()) {
                EditorGUILayout.PrefixLabel("Size");
                using (ShapesUI.TempLabelWidth(14)) {
                    EditorGUILayout.PropertyField(propWidth, new GUIContent("X"), GUILayout.MinWidth(20));
                    EditorGUILayout.PropertyField(propHeight, new GUIContent("Y"), GUILayout.MinWidth(20));
                }
            }

            bool isHollow = ((Rectangle)target).IsHollow;

            using (new EditorGUI.DisabledScope(!multiEditing && isHollow == false)) {
                EditorGUILayout.PropertyField(propThickness);
            }

            bool hasRadius = ((Rectangle)target).IsRounded;

            using (new EditorGUI.DisabledScope(hasRadius == false)) {
                EditorGUILayout.PropertyField(propCornerRadiusMode, new GUIContent("Radius Mode"));
                CornerRadiusProperties();
            }

            base.EndProperties();
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            base.BeginProperties();
            bool multiEditing = serializedObject.isEditingMultipleObjects;

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

            EditorGUILayout.PropertyField(propPivot);
            using (new EditorGUILayout.HorizontalScope()) {
                EditorGUILayout.PrefixLabel("Size");
                using (ShapesUI.TempLabelWidth(14)) {
                    EditorGUILayout.PropertyField(propWidth, new GUIContent("X"), GUILayout.MinWidth(20));
                    EditorGUILayout.PropertyField(propHeight, new GUIContent("Y"), GUILayout.MinWidth(20));
                }
            }

            bool isBorder = ((Rectangle)target).IsBorder;

            using (new EditorGUI.DisabledScope(!multiEditing && isBorder == false))
                ShapesUI.FloatInSpaceField(propThickness, propThicknessSpace);

            bool hasRadius = ((Rectangle)target).IsRounded;

            using (new EditorGUI.DisabledScope(hasRadius == false)) {
                EditorGUILayout.PropertyField(propCornerRadiusMode, new GUIContent("Radius Mode"));
                CornerRadiusProperties();
            }

            rectEditor.GUIEditButton();

            bool hasDashablesInSelection = targets.Any(x => (x as Rectangle).IsBorder);

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

            fillEditor.DrawProperties(this);

            base.EndProperties();
        }
        protected void BeginProperties(bool showColor = true)
        {
            soRnd.Update();
            using (ShapesUI.Horizontal) {
                using (ShapesUI.TempFieldWidth(180f))
                    ShapesUI.RenderSortingLayerField(propSortingLayer);
                using (ShapesUI.TempLabelWidth(40f))
                    EditorGUILayout.PropertyField(propSortingOrder, new GUIContent("Order"));
            }

            EditorGUILayout.PropertyField(propBlendMode, blendModeGuiContent);
            if ((target as ShapeRenderer).HasScaleModes)
            {
                EditorGUILayout.PropertyField(propScaleMode, scaleModeGuiContent);
            }
            if (showColor)
            {
                PropertyFieldColor();
            }
        }
Beispiel #4
0
        protected void BeginProperties(bool showColor = true, bool canEditDetailLevel = true)
        {
            soRnd.Update();

            using (new ShapesUI.GroupScope()) {
                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)) {
                            EditorGUILayout.PropertyField(propRenderQueue, renderQueueGuiContent);
                            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;
                            propRenderQueue.intValue         = ShapeRenderer.DEFAULT_RENDER_QUEUE_AUTO;
                        }
                    }
                }
            }

            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();
            }
        }