Exemple #1
0
        public bool BeginFoldout(bool foldout, string label, int indentLevel, bool drawLine, ColorValue lineColor)
        {
            var backgroundColor = GUI.backgroundColor;
            var contentColor    = GUI.contentColor;

            GUI.backgroundColor = foldout ? backgroundColor : MightyColorUtilities.DarkenColor(backgroundColor, .3f);
            GUI.contentColor    = foldout ? contentColor : MightyColorUtilities.DarkenColor(contentColor, .25f);

            GUILayout.BeginVertical(MightyStyleUtilities.GetFoldAreaHeader(indentLevel));
            EditorGUI.indentLevel = 1;

            GUILayout.BeginVertical(MightyStyles.FoldBoxHeaderContent);
            foldout = MightyGUIUtilities.DrawFoldout(foldout, label, MightyStyles.FoldAreaLabel);
            GUILayout.EndVertical();

            if (!foldout)
            {
                EditorGUI.indentLevel = indentLevel;
                GUILayout.EndVertical();
            }
            else if (drawLine)
            {
                DrawLine(lineColor);
            }

            GUI.backgroundColor = backgroundColor;
            GUI.contentColor    = contentColor;

            return(foldout);
        }
Exemple #2
0
        public override void BeginDrawGroup(int indentLevel = 0, string groupID = null, bool indentInside = true)
        {
            GUILayout.BeginVertical(MightyStyleUtilities.GetDarkBox(indentLevel));

            if (indentInside)
            {
                EditorGUI.indentLevel = 1;
            }
        }
Exemple #3
0
        public bool BeginFoldout(bool foldout, string label, int indentLevel)
        {
            GUILayout.BeginVertical(MightyStyleUtilities.GetFoldBoxHeader(indentLevel));
            EditorGUI.indentLevel = 1;

            GUILayout.BeginVertical(MightyStyles.FoldBoxHeaderContent);
            foldout = MightyGUIUtilities.DrawFoldout(foldout, label, MightyStyles.BoldFoldout);
            GUILayout.EndVertical();

            if (foldout)
            {
                return(true);
            }
            EditorGUI.indentLevel = indentLevel;
            GUILayout.EndVertical();
            return(false);
        }
Exemple #4
0
 protected override float GetDecoratorHeight(MightySerializedField serializedField, int index, LineAttribute attribute) =>
 MightyStyleUtilities.GetLineHeight(true);
Exemple #5
0
        protected override void DrawArrayImpl(MightySerializedField serializedField, ButtonArrayAttribute attribute, ArrayOption options,
                                              BaseArrayDecoratorAttribute[] decoratorAttributes, IArrayElementDrawer drawer, BasePropertyDrawerAttribute drawerAttribute)
        {
            var property = serializedField.Property;

            foreach (var decoratorAttribute in decoratorAttributes)
            {
                ((IArrayDecoratorDrawer)decoratorAttribute.Drawer).BeginDrawArray(serializedField, decoratorAttribute);
            }

            foreach (var decoratorAttribute in decoratorAttributes)
            {
                ((IArrayDecoratorDrawer)decoratorAttribute.Drawer).BeginDrawHeader(serializedField, decoratorAttribute);
            }

            if (!options.Contains(ArrayOption.HideLabel))
            {
                if (options.Contains(ArrayOption.DontFold))
                {
                    EditorGUILayout.LabelField(property.displayName,
                                               options.Contains(ArrayOption.BoldLabel) ? EditorStyles.boldLabel : EditorStyles.label);
                    property.isExpanded = true;
                }
                else if (!MightyGUIUtilities.DrawFoldout(property,
                                                         options.Contains(ArrayOption.BoldLabel) ? MightyStyles.BoldFoldout : null))
                {
                    foreach (var decoratorAttribute in decoratorAttributes)
                    {
                        ((IArrayDecoratorDrawer)decoratorAttribute.Drawer).EndDrawHeader(serializedField, decoratorAttribute);
                    }

                    foreach (var decoratorAttribute in decoratorAttributes)
                    {
                        ((IArrayDecoratorDrawer)decoratorAttribute.Drawer).EndDrawArray(serializedField, decoratorAttribute);
                    }

                    return;
                }
            }
            else
            {
                property.isExpanded = true;
            }

            if (!options.Contains(ArrayOption.DontIndent))
            {
                EditorGUI.indentLevel++;
            }

            foreach (var decoratorAttribute in decoratorAttributes)
            {
                ((IArrayDecoratorDrawer)decoratorAttribute.Drawer).EndDrawHeader(serializedField, decoratorAttribute);
            }


            GUILayout.BeginVertical(MightyStyleUtilities.GetButtonArray(EditorGUI.indentLevel - 1), GUILayout.MinHeight(35));
            var indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            if (property.arraySize == 0)
            {
                GUILayout.FlexibleSpace();
                if (MightyGUIUtilities.DrawAddButton())
                {
                    property.InsertArrayElementAtIndex(0);
                    property.serializedObject.ApplyModifiedProperties();
                }

                GUILayout.FlexibleSpace();
            }

            MightyGUIUtilities.DrawArrayBody(property, index =>
            {
                var element = property.GetArrayElementAtIndex(index);

                foreach (var decoratorAttribute in decoratorAttributes)
                {
                    ((IArrayDecoratorDrawer)decoratorAttribute.Drawer).BeginDrawElement(serializedField, index,
                                                                                        decoratorAttribute);
                }

                GUILayout.BeginHorizontal(GUILayout.MinHeight(33));

                GUILayout.BeginVertical(GUILayout.Width(1));
                GUILayout.FlexibleSpace();
                GUILayout.BeginHorizontal();

                if (MightyGUIUtilities.DrawRemoveButton())
                {
                    property.DeleteArrayElementAtIndex(index);
                    property.serializedObject.ApplyModifiedProperties();

                    GUILayout.EndHorizontal();

                    foreach (var decoratorAttribute in decoratorAttributes)
                    {
                        ((IArrayDecoratorDrawer)decoratorAttribute.Drawer).EndDrawElement(serializedField, index,
                                                                                          decoratorAttribute);
                    }
                    return;
                }

                if (MightyGUIUtilities.DrawAddButton())
                {
                    property.InsertArrayElementAtIndex(index);
                    property.serializedObject.ApplyModifiedProperties();
                }

                if (serializedField.IsFoldable())
                {
                    GUILayout.Space(10);
                }

                GUILayout.EndHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();

                GUILayout.BeginVertical();
                GUILayout.FlexibleSpace();

                if (drawer != null)
                {
                    drawer.DrawElement(serializedField, index, drawerAttribute);
                }
                else if (options.Contains(ArrayOption.HideElementLabel))
                {
                    EditorGUILayout.PropertyField(element, GUIContent.none);
                }
                else
                {
                    EditorGUILayout.PropertyField(element);
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();

                foreach (var decoratorAttribute in decoratorAttributes)
                {
                    ((IArrayDecoratorDrawer)decoratorAttribute.Drawer).EndDrawElement(serializedField, index, decoratorAttribute);
                }
            });

            EditorGUI.indentLevel = indent;
            GUILayout.EndVertical();

            if (!options.Contains(ArrayOption.DontIndent))
            {
                EditorGUI.indentLevel--;
            }

            foreach (var decoratorAttribute in decoratorAttributes)
            {
                ((IArrayDecoratorDrawer)decoratorAttribute.Drawer).EndDrawArray(serializedField, decoratorAttribute);
            }
        }
Exemple #6
0
 public override GUIStyle GetGroupStyle(int indentLevel) => MightyStyleUtilities.GetDarkBox(indentLevel);