コード例 #1
0
 public override void OnInspectorGUI()
 {
     base.BeginProperties();
     ShapesUI.FloatInSpaceField(propRadius, propRadiusSpace);
     ShapesUI.FloatInSpaceField(propThickness, propThicknessSpace);
     base.EndProperties();
 }
コード例 #2
0
        void DrawStyleGUI()
        {
            bool canSetStyle = !isLine || (propGeometry.hasMultipleDifferentValues || propGeometry.enumValueIndex != (int)LineGeometry.Volumetric3D);

            if (canSetStyle)
            {
                using (new EditorGUILayout.HorizontalScope()) {
                    EditorGUILayout.PrefixLabel("Style");
                    ShapesUI.DrawTypeSwitchButtons(propType, UIAssets.LineDashButtonContents);
                }

                bool canEditStyle = propShapeModifier.hasMultipleDifferentValues || ((DashType)propType.enumValueIndex).HasModifier();
                using (new EditorGUI.DisabledScope(canEditStyle == false))
                    EditorGUILayout.PropertyField(propShapeModifier);
            }
            else                 // this else is only applicable for lines
            {
                using (new EditorGUI.DisabledScope(true)) {
                    using (new EditorGUILayout.HorizontalScope()) {
                        EditorGUILayout.PrefixLabel(new GUIContent("Style", "3D lines support basic dashes only"));
                        GUILayout.Toggle(true, UIAssets.LineDashButtonContents[0], ShapesUI.GetMiniButtonStyle(0, 3), GUILayout.MinHeight(20));
                        GUILayout.Toggle(false, UIAssets.LineDashButtonContents[1], ShapesUI.GetMiniButtonStyle(1, 3), GUILayout.MinHeight(20));
                        GUILayout.Toggle(false, UIAssets.LineDashButtonContents[2], ShapesUI.GetMiniButtonStyle(2, 3), GUILayout.MinHeight(20));
                    }
                }
            }
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        public override void OnInspectorGUI()
        {
            base.BeginProperties();
            if (Event.current.type == EventType.Layout)
            {
                showZ = targets.Any(x => ((Polyline)x).Geometry != PolylineGeometry.Flat2D);
            }
            EditorGUILayout.PropertyField(propGeometry);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(propJoins);
            ShapesUI.FloatInSpaceField(propThickness, propThicknessSpace);

            if (hasManyPoints)                // to prevent lag when inspecting polylines with many points
            {
                string foldoutLabel = showPointList ? "Hide" : "Show Points";
                showPointList = GUILayout.Toggle(showPointList, foldoutLabel, EditorStyles.foldout);
            }

            if (showPointList)
            {
                pointList.DoLayoutList();
            }

            scenePointEditor.GUIEditButton("Edit Points in Scene");

            base.EndProperties();
        }
コード例 #5
0
        public override void OnInspectorGUI()
        {
            base.BeginProperties();
            EditorGUILayout.PropertyField(propGeometry);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(propJoins);
            ShapesUI.FloatInSpaceField(propThickness, propThicknessSpace);

            if (hasManyPoints)                // to prevent lag when inspecting polylines with many points
            {
                string foldoutLabel = showPointList ? "Hide" : "Show Points";
                showPointList = GUILayout.Toggle(showPointList, foldoutLabel, EditorStyles.foldout);
            }

            if (showPointList)
            {
                pointList.DoLayoutList();
            }

            scenePointEditor.GUIEditButton("Edit Points in Scene");

            if (base.EndProperties())
            {
                UpdateMesh();
            }
        }
コード例 #6
0
        public override void OnInspectorGUI()
        {
            base.BeginProperties(showColor: true);

            EditorGUILayout.PropertyField(propGeometry);
            ShapesUI.DrawTypeSwitchButtons(propSides, SideCountTypes, indexToPolygonPreset);
            //ShapesUI.EnumButtonRow(); // todo
            EditorGUILayout.PropertyField(propSides);
            EditorGUILayout.PropertyField(propRoundness);

            ShapesUI.FloatInSpaceField(propRadius, propRadiusSpace);

            EditorGUILayout.PropertyField(propHollow);
            using (new EditorGUI.DisabledScope(propHollow.boolValue == false || propHollow.hasMultipleDifferentValues))
                ShapesUI.FloatInSpaceField(propThickness, propThicknessSpace);
            ShapesUI.AngleProperty(propAngle, "Angle", propAngUnitInput, angLabelLayout);
            ShapesUI.DrawAngleSwitchButtons(propAngUnitInput);

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

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

            fillEditor.DrawProperties(this);

            base.EndProperties();
        }
コード例 #7
0
 public override void OnInspectorGUI()
 {
     serializedObject.Update();
     base.BeginProperties();
     ShapesUI.FloatInSpaceField(propSize, propSizeSpace);
     serializedObject.ApplyModifiedProperties();
 }
コード例 #8
0
 void DrawAngleProperties(DiscType selectedType)
 {
     using (new EditorGUI.DisabledScope(selectedType.HasSector() == false && serializedObject.isEditingMultipleObjects == false)) {
         ShapesUI.AngleProperty(propAngRadiansStart, "Angle start", propAngUnitInput, angLabelLayout);
         ShapesUI.AngleProperty(propAngRadiansEnd, "Angle end", propAngUnitInput, angLabelLayout);
         ShapesUI.DrawAngleSwitchButtons(propAngUnitInput);
     }
 }
コード例 #9
0
ファイル: ShapesUI.cs プロジェクト: pencilking2002/BioTower
 public static void DrawAngleSwitchButtons(SerializedProperty prop)
 {
     GUILayout.BeginHorizontal();
     EditorGUILayout.PrefixLabel(" ");
     GUIContent[] angLabels = (Screen.width < 300) ? UIAssets.AngleUnitButtonContentsShort : UIAssets.AngleUnitButtonContents;
     ShapesUI.DrawTypeSwitchButtons(prop, angLabels, null, 15);
     GUILayout.EndHorizontal();
 }
コード例 #10
0
ファイル: ShapesUI.cs プロジェクト: pencilking2002/BioTower
        public static bool DrawTypeSwitchButtons(SerializedProperty prop, GUIContent[] guiContent, int[] indexOverride = null, int height = 20)
        {
            int GetEntryCount()
            {
                switch (prop.propertyType)
                {
                case SerializedPropertyType.Enum:    return(prop.enumNames.Length);

                case SerializedPropertyType.Integer: return(indexOverride.Length);

                default:                             throw new IndexOutOfRangeException("no, illegal >:I");
                }
            }

            bool[] multiselectPressedState = prop.TryGetMultiselectPressedStates(indexOverride, GetEntryCount());

            bool             changed     = false;
            SerializedObject so          = prop.serializedObject;
            bool             multiselect = so.isEditingMultipleObjects;

            EditorGUI.BeginChangeCheck();
            GUILayoutOption[] buttonLayout = { GUILayout.Height(height), GUILayout.MinWidth(height) };

            void EnumButton(int index)
            {
                GUIStyle style = ShapesUI.GetMiniButtonStyle(index, guiContent.Length);
                bool     btnState;

                if (multiselect)
                {
                    btnState = multiselectPressedState[index];
                }
                else
                {
                    btnState = index == prop.GetIntValue(indexOverride) && prop.hasMultipleDifferentValues == false;
                }
                bool btnStateNew = GUILayout.Toggle(btnState, guiContent[index], style, buttonLayout);

                bool pressedInMultiselect  = multiselect && btnState != btnStateNew;
                bool pressedInSingleselect = multiselect == false && btnStateNew && btnState == false;

                if (pressedInMultiselect || pressedInSingleselect)
                {
                    prop.SetIntValue(index, indexOverride);
                    changed = true;
                }
            }

            GUILayout.BeginHorizontal();
            for (int i = 0; i < guiContent.Length; i++)
            {
                EnumButton(i);
            }
            GUILayout.EndHorizontal();
            return(changed);
        }
コード例 #11
0
 void DrawAngleProperties(DiscType selectedType)
 {
     using (new EditorGUI.DisabledScope(selectedType.HasSector() == false && serializedObject.isEditingMultipleObjects == false)) {
         ShapesUI.AngleProperty(propAngRadiansStart, "Angle start", propAngUnitInput, angLabelLayout);
         ShapesUI.AngleProperty(propAngRadiansEnd, "Angle end", propAngUnitInput, angLabelLayout);
         GUILayout.BeginHorizontal();
         EditorGUILayout.PrefixLabel(" ");
         GUIContent[] angLabels = (Screen.width < 300) ? ShapesAssets.AngleUnitButtonContentsShort : ShapesAssets.AngleUnitButtonContents;
         ShapesUI.DrawTypeSwitchButtons(propAngUnitInput, angLabels, 15);
         GUILayout.EndHorizontal();
     }
 }
コード例 #12
0
        // Draws the elements on the list
        void DrawPointElement(Rect r, int i, bool isActive, bool isFocused)
        {
            r.yMin += 1;
            r.yMax -= 2;
            SerializedProperty prop       = propPolyPoints.GetArrayElementAtIndex(i);
            SerializedProperty pPoint     = prop.FindPropertyRelative(nameof(PolylinePoint.point));
            SerializedProperty pThickness = prop.FindPropertyRelative(nameof(PolylinePoint.thickness));
            SerializedProperty pColor     = prop.FindPropertyRelative(nameof(PolylinePoint.color));

            ShapesUI.PosThicknessColorField(r, pPoint, pThickness, pColor);
            pThickness.floatValue = Mathf.Max(0.001f, pThickness.floatValue);               // Make sure it's never 0 or under
        }
コード例 #13
0
        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();
        }
コード例 #14
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            base.BeginProperties(showColor: false);
            EditorGUILayout.PropertyField(propColorMode);

            bool    dEnabled = propAutoSetD.boolValue == false;
            Vector3 dAuto    = (target as Quad).DAuto;

            switch ((Quad.QuadColorMode)propColorMode.enumValueIndex)
            {
            case Quad.QuadColorMode.Single:
                ShapesUI.PosColorField("A", propA, base.propColor);
                ShapesUI.PosColorField("B", propB, base.propColor, false);
                ShapesUI.PosColorField("C", propC, base.propColor, false);
                ShapesUI.PosColorFieldSpecialOffState("D", propD, dAuto, base.propColor, false, dEnabled);
                break;

            case Quad.QuadColorMode.Horizontal:
                ShapesUI.PosColorField("A", propA, base.propColor);
                ShapesUI.PosColorField("B", propB, base.propColor, false);
                ShapesUI.PosColorField("C", propC, propColorC);
                ShapesUI.PosColorFieldSpecialOffState("D", propD, dAuto, propColorC, false, dEnabled);
                break;

            case Quad.QuadColorMode.Vertical:
                ShapesUI.PosColorField("A", propA, propColorD);
                ShapesUI.PosColorField("B", propB, propColorB);
                ShapesUI.PosColorField("C", propC, propColorB, false);
                ShapesUI.PosColorFieldSpecialOffState("D", propD, dAuto, propColorD, false, dEnabled);
                break;

            case Quad.QuadColorMode.PerCorner:
                ShapesUI.PosColorField("A", propA, base.propColor);
                ShapesUI.PosColorField("B", propB, propColorB);
                ShapesUI.PosColorField("C", propC, propColorC);
                ShapesUI.PosColorFieldSpecialOffState("D", propD, dAuto, propColorD, true, dEnabled);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            using (new EditorGUILayout.HorizontalScope()) {
                GUILayout.Label(GUIContent.none, GUILayout.Width(ShapesUI.POS_COLOR_FIELD_LABEL_WIDTH));
                EditorGUILayout.PropertyField(propAutoSetD, GUIContent.none, GUILayout.Width(16));
                GUILayout.Label("Auto-set D");
            }

            base.EndProperties();
        }
コード例 #15
0
 public override void OnInspectorGUI()
 {
     base.BeginProperties();
     ShapesUI.FloatInSpaceField(propRadius, propSizeSpace);
     ShapesUI.FloatInSpaceField(propLength, propSizeSpace, spaceEnabled: false);
     EditorGUILayout.PropertyField(propFillCap);
     if (base.EndProperties())
     {
         foreach (Cone cone in targets.Cast <Cone>())
         {
             cone.UpdateMesh();
         }
     }
 }
コード例 #16
0
        // Draws the elements on the list
        void DrawPointElement(Rect r, int i, bool isActive, bool isFocused)
        {
            r.yMin += 1;
            r.yMax -= 2;
            SerializedProperty prop       = propPoints.GetArrayElementAtIndex(i);
            SerializedProperty pPoint     = prop.FindPropertyRelative(nameof(PolylinePoint.point));
            SerializedProperty pThickness = prop.FindPropertyRelative(nameof(PolylinePoint.thickness));
            SerializedProperty pColor     = prop.FindPropertyRelative(nameof(PolylinePoint.color));

            using (var chChk = new EditorGUI.ChangeCheckScope()) {
                ShapesUI.PosThicknessColorField(r, pPoint, pThickness, pColor, colorEnabled: true, showZ);
                if (chChk.changed)
                {
                    pThickness.floatValue = Mathf.Max(0.001f, pThickness.floatValue);                       // Make sure it's never 0 or under
                }
            }
        }
コード例 #17
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();
        }
コード例 #18
0
        public static bool DrawTypeSwitchButtons(SerializedProperty enumProp, GUIContent[] guiContent, int height = 32)
        {
            bool[] multiselectPressedState = enumProp.TryGetMultiselectPressedStates();

            bool             changed     = false;
            SerializedObject so          = enumProp.serializedObject;
            bool             multiselect = so.isEditingMultipleObjects;

            EditorGUI.BeginChangeCheck();
            GUILayoutOption[] buttonLayout = { GUILayout.Height(height), GUILayout.MinWidth(height) };

            void EnumButton(int index)
            {
                GUIStyle style = ShapesUI.GetMiniButtonStyle(index, guiContent.Length);
                bool     btnState;

                if (multiselect)
                {
                    btnState = multiselectPressedState[index];
                }
                else
                {
                    btnState = index == enumProp.enumValueIndex && enumProp.hasMultipleDifferentValues == false;
                }
                bool btnStateNew = GUILayout.Toggle(btnState, guiContent[index], style, buttonLayout);

                bool pressedInMultiselect  = multiselect && btnState != btnStateNew;
                bool pressedInSingleselect = multiselect == false && btnStateNew && btnState == false;

                if (pressedInMultiselect || pressedInSingleselect)
                {
                    enumProp.enumValueIndex = index;
                    changed = true;
                }
            }

            GUILayout.BeginHorizontal();
            for (int i = 0; i < guiContent.Length; i++)
            {
                EnumButton(i);
            }
            GUILayout.EndHorizontal();
            return(changed);
        }
コード例 #19
0
        public override void OnInspectorGUI()
        {
            base.BeginProperties(showColor: false);

            EditorGUILayout.PropertyField(propColorMode);
            if (propColorMode.enumValueIndex == (int)Triangle.TriangleColorMode.Single)
            {
                ShapesUI.PosColorField("A", propA, base.propColor);
                ShapesUI.PosColorField("B", propB, base.propColor, false);
                ShapesUI.PosColorField("C", propC, base.propColor, false);
            }
            else
            {
                ShapesUI.PosColorField("A", propA, base.propColor);
                ShapesUI.PosColorField("B", propB, propColorB);
                ShapesUI.PosColorField("C", propC, propColorC);
            }

            base.EndProperties();
        }
コード例 #20
0
        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();
            }
        }
コード例 #21
0
 public override void OnInspectorGUI()
 {
     base.BeginProperties();
     ShapesUI.FloatInSpaceField(propSize, propSizeSpace);
     base.EndProperties();
 }
コード例 #22
0
        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();
            }
        }
コード例 #23
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();
            }
        }
コード例 #24
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);

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

            base.EndProperties();
        }
コード例 #25
0
ファイル: LineEditor.cs プロジェクト: Kvinster/LD48Project
        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();
                }
            }
        }
コード例 #26
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();
                }
            }
        }