示例#1
0
        public override void EndDraw(BaseMightyMember mightyMember, BaseElementDecoratorAttribute baseAttribute,
                                     Action <BaseMightyMember, SerializedProperty, BaseDrawerAttribute> propertyDrawCallback,
                                     BaseDrawerAttribute drawerAttribute = null)
        {
            var property = mightyMember.Property;

            if (!property.isArray)
            {
                EndDraw(mightyMember, baseAttribute);
                return;
            }

            if (!property.isExpanded)
            {
                return;
            }

            EditorDrawUtility.DrawArrayBody(property, index =>
            {
                BeginDrawElement(mightyMember, index, baseAttribute);
                propertyDrawCallback?.Invoke(mightyMember, property.GetArrayElementAtIndex(index), drawerAttribute);
                EndDrawElement(mightyMember, index, baseAttribute);
            });

            EditorGUI.indentLevel--;

            EndDrawArray(mightyMember, baseAttribute);
        }
        public void DrawLayerField(Rect rect, SerializedProperty property, BaseDrawerAttribute attribute, GUIContent label = null)
        {
            if (property.propertyType != SerializedPropertyType.Integer)
            {
                EditorDrawUtility.DrawPropertyField(rect, property);
                rect.y      += 18;
                rect.height -= 24;
                EditorDrawUtility.DrawHelpBox(rect, $"\"{property.displayName}\" should be of type int");
                return;
            }

            int layer;

            if (attribute.Option.Contains(FieldOption.HideLabel))
            {
                layer = EditorGUI.LayerField(rect, property.intValue);
            }
            else if (attribute.Option.Contains(FieldOption.BoldLabel))
            {
                layer = EditorGUI.LayerField(rect, label ?? EditorGUIUtility.TrTextContent(property.displayName), property.intValue,
                                             EditorStyles.boldLabel);
            }
            else
            {
                layer = EditorGUI.LayerField(rect, label ?? EditorGUIUtility.TrTextContent(property.displayName), property.intValue);
            }

            property.intValue = layer;
        }
示例#3
0
        public override void BeginDraw(BaseMightyMember mightyMember, BaseElementDecoratorAttribute baseAttribute,
                                       Action <BaseMightyMember, SerializedProperty, BaseDrawerAttribute> propertyDrawCallback,
                                       BaseDrawerAttribute drawerAttribute = null)
        {
            var property = mightyMember.Property;

            if (!property.isArray)
            {
                BeginDraw(mightyMember, baseAttribute);

                propertyDrawCallback?.Invoke(mightyMember, property, drawerAttribute);
                return;
            }

            BeginDrawArray(mightyMember, baseAttribute);
            BeginDrawHeader(mightyMember, baseAttribute);

            if (!EditorDrawUtility.DrawFoldout(property))
            {
                EndDrawHeader(mightyMember, baseAttribute);
                EndDrawArray(mightyMember, baseAttribute);
                return;
            }

            EditorGUI.indentLevel++;
            EditorDrawUtility.DrawArraySizeField(property);

            EndDrawHeader(mightyMember, baseAttribute);
        }
        public void DrawElement(Rect rect, BaseMightyMember mightyMember, int index, BaseDrawerAttribute baseAttribute)
        {
            GetDrawerForMember(mightyMember, m_elementCallback, out var drawerMethod, baseAttribute);

            InvokeDrawer(drawerMethod,
                         $"void {((CustomDrawerAttribute) baseAttribute).DrawerCallback}(Rect rect, SerializedProperty property, SerializedProperty element, int index)",
                         rect, mightyMember.Property, mightyMember.GetElement(index), index);
        }
示例#5
0
 public override void EndDraw(BaseMightyMember mightyMember, BaseElementDecoratorAttribute baseAttribute,
                              Action <BaseMightyMember, SerializedProperty, BaseDrawerAttribute> propertyDrawCallback,
                              BaseDrawerAttribute drawerAttribute = null)
 {
     if (!mightyMember.Property.isArray && baseAttribute is EndHorizontalAttribute || baseAttribute is HorizontalAttribute)
     {
         GUILayout.EndHorizontal();
     }
 }
示例#6
0
        private void DrawArea(Rect rect, SerializedProperty property, BaseDrawerAttribute attribute)
        {
            if (property.propertyType != SerializedPropertyType.Vector4)
            {
                EditorDrawUtility.DrawHelpBox(rect, $"{property.name} should be of type UnityEngine.Vector4");
                return;
            }

            property.vector4Value = DrawArea(rect, EditorGUIUtility.TrTextContent(property.displayName), property.vector4Value, attribute);
        }
 private bool GetDrawerForMember(BaseMightyMember member, CallbackSignature signature, out MightyMethod <object> drawerMethod,
                                 BaseDrawerAttribute attribute)
 {
     if (GetDrawerForMember(member.ID, signature, out drawerMethod))
     {
         return(true);
     }
     InitDrawer(member, attribute);
     return(GetDrawerForMember(member.ID, signature, out drawerMethod));
 }
        private void DrawMargins(SerializedProperty property, BaseDrawerAttribute attribute, GUIContent label = null)
        {
            if (property.propertyType != SerializedPropertyType.Vector4)
            {
                EditorDrawUtility.DrawHelpBox($"{property.name} should be of type UnityEngine.Vector4");
                return;
            }

            property.vector4Value = DrawMargins(EditorGUILayout.GetControlRect(true, 32),
                                                label ?? EditorGUIUtility.TrTextContent(property.displayName), property.vector4Value, attribute);
        }
示例#9
0
        private void DrawAssetField(Rect rect, SerializedProperty property, BaseDrawerAttribute attribute)
        {
            if (property.propertyType != SerializedPropertyType.ObjectReference)
            {
                EditorDrawUtility.DrawHelpBox($"{property.name} should be of type UnityEngine.Object");
                return;
            }


            property.objectReferenceValue = attribute.Option.Contains(FieldOption.HideLabel)
                ? EditorGUI.ObjectField(rect, property.objectReferenceValue, property.GetSystemType(), false)
                : EditorGUI.ObjectField(rect, property.displayName, property.objectReferenceValue, property.GetSystemType(), false);
        }
示例#10
0
        private void DrawAssetField(SerializedProperty property, BaseDrawerAttribute attribute, GUIContent label = null)
        {
            if (property.propertyType != SerializedPropertyType.ObjectReference)
            {
                EditorDrawUtility.DrawHelpBox($"{property.name} should be of type UnityEngine.Object");
                return;
            }

            property.objectReferenceValue = attribute.Option.Contains(FieldOption.HideLabel)
                ? EditorGUILayout.ObjectField(property.objectReferenceValue, property.GetSystemType(), false)
                : EditorGUILayout.ObjectField(label ?? EditorGUIUtility.TrTextContent(property.displayName),
                                              property.objectReferenceValue, property.GetSystemType(), false);
        }
        public float GetElementHeight(BaseMightyMember mightyMember, int index, BaseDrawerAttribute baseAttribute)
        {
            if (string.IsNullOrWhiteSpace(((CustomDrawerAttribute)baseAttribute).ElementHeightCallback))
            {
                return(0);
            }

            if (!GetDrawerForMember(mightyMember, m_elementCallback, out var callback, baseAttribute))
            {
                return(0);
            }

            return((float)callback.Invoke());
        }
示例#12
0
        public override void DrawField(MightyMember <FieldInfo> mightyMember, BaseDrawerAttribute baseAttribute)
        {
            var attribute = (ShowNonSerializedAttribute)baseAttribute;
            var field     = mightyMember.MemberInfo;
            var value     = field.GetValue(mightyMember.Target);

            if (EditorDrawUtility.DrawLayoutField(attribute.DrawPrettyName ? field.Name.DrawPrettyName() : field.Name, value,
                                                  attribute.Enabled))
            {
                return;
            }

            EditorDrawUtility.DrawHelpBox($"{typeof(ShowNonSerializedAttribute).Name} doesn't support {field.FieldType.Name} types");
        }
示例#13
0
        private Vector4 DrawArea(Rect position, GUIContent label, Vector4 area, BaseDrawerAttribute attribute)
        {
            var areaArray = area.Vector4ToArray();

            DrawLabel(ref position, null, attribute, label);

            EditorGUI.BeginChangeCheck();
            EditorDrawUtility.MultiFloatField(position, AreaContent, areaArray, AreaWidths, Orientation.Vertical);
            if (EditorGUI.EndChangeCheck())
            {
                area = areaArray.ArrayToVector4();
            }

            return(area);
        }
示例#14
0
        public override void DrawField(MightyMember <FieldInfo> mightyMember, BaseDrawerAttribute baseAttribute)
        {
            var attribute = (EditorSerializeAttribute)baseAttribute;
            var context   = mightyMember.Context;
            var field     = mightyMember.MemberInfo;
            var target    = mightyMember.Target;

            if (attribute.OldName != null)
            {
                EditorFieldsDatabase.RenameField(context, attribute.OldName, field.Name);
            }

            if (attribute.Options == EditorFieldOption.Hide)
            {
                return;
            }

            var editorField = EditorFieldsDatabase.GetEditorField(context, field.Name);
            var value       = field.GetValue(target);

            if (attribute.Options.Contains(EditorFieldOption.Deserialize))
            {
                Deserialize(attribute, editorField, target, field, ref value);
            }

            if (attribute.Options.Contains(EditorFieldOption.Hide) &&
                field.GetCustomAttribute(typeof(HideAttribute), true) is HideAttribute)
            {
                if (attribute.Options.Contains(EditorFieldOption.Serialize))
                {
                    Serialize(attribute, editorField, value, field.FieldType);
                }
                return;
            }

            if (attribute.Options.Contains(EditorFieldOption.Hide))
            {
                return;
            }

            EditorGUI.BeginChangeCheck();

            if (field.GetCustomAttribute(typeof(CustomDrawerAttribute), true) is CustomDrawerAttribute drawerAttribute &&
                (DrawersDatabase.GetDrawerForAttribute <CustomDrawerPropertyDrawer>(typeof(CustomDrawerAttribute)) is var drawer))
            {
                value = drawer.DrawField(field, context, value, drawerAttribute);
            }
示例#15
0
        private static void DrawEuler(Rect position, SerializedProperty property, BaseDrawerAttribute attribute)
        {
            if (property.propertyType != SerializedPropertyType.Quaternion)
            {
                EditorDrawUtility.DrawHelpBox(position, $"{property.name} should be of type Quaternion");
                return;
            }

            if (attribute.Option.Contains(FieldOption.HideLabel))
            {
                EditorDrawUtility.DrawRotationEuler(position, GUIContent.none, property);
            }
            else
            {
                EditorDrawUtility.DrawRotationEuler(position, property);
            }
        }
示例#16
0
        private static void DrawEuler(SerializedProperty property, BaseDrawerAttribute attribute, GUIContent label = null)
        {
            if (property.propertyType != SerializedPropertyType.Quaternion)
            {
                EditorDrawUtility.DrawHelpBox($"{property.name} should be of type Quaternion");
                return;
            }

            if (attribute.Option.Contains(FieldOption.HideLabel))
            {
                EditorDrawUtility.DrawRotationEuler(GUIContent.none, property);
            }
            else
            {
                EditorDrawUtility.DrawRotationEuler(label ?? EditorGUIUtility.TrTextContent(property.displayName), property);
            }
        }
示例#17
0
        protected virtual bool DrawLabel(ref Rect rect, SerializedProperty property, BaseDrawerAttribute baseAttribute, GUIContent label)
        {
            if (baseAttribute.Option.Contains(FieldOption.HideLabel))
            {
                return(false);
            }

            if (baseAttribute.Option.Contains(FieldOption.BoldLabel))
            {
                EditorGUI.LabelField(rect, label ?? EditorGUIUtility.TrTextContent(property.displayName), EditorStyles.boldLabel);
            }
            else
            {
                EditorGUI.LabelField(rect, label ?? EditorGUIUtility.TrTextContent(property.displayName));
            }

            return(true);
        }
示例#18
0
        private void DrawRotation2D(Rect rect, SerializedProperty property, BaseDrawerAttribute attribute)
        {
            if (property.propertyType != SerializedPropertyType.Quaternion)
            {
                EditorDrawUtility.DrawHelpBox(rect, $"{property.name} should be of type Quaternion");
                return;
            }

            var quaternion = property.quaternionValue;
            var angles     = quaternion.eulerAngles;

            angles.z = attribute.Option.Contains(FieldOption.HideLabel)
                ? EditorGUI.Slider(rect, angles.z, 0, 359.9f)
                : EditorGUI.Slider(rect, property.displayName, angles.z, 0, 359.9f);

            quaternion.eulerAngles   = angles;
            property.quaternionValue = quaternion;
        }
示例#19
0
        private void DrawRotation2D(SerializedProperty property, BaseDrawerAttribute attribute, GUIContent label = null)
        {
            if (property.propertyType != SerializedPropertyType.Quaternion)
            {
                EditorDrawUtility.DrawHelpBox($"{property.name} should be of type Quaternion");
                return;
            }

            var quaternion = property.quaternionValue;
            var angles     = quaternion.eulerAngles;

            angles.z = attribute.Option.Contains(FieldOption.HideLabel)
                ? EditorGUILayout.Slider(angles.z, 0, 359.9f)
                : EditorGUILayout.Slider(label ?? EditorGUIUtility.TrTextContent(property.displayName), angles.z, 0, 359.9f);

            quaternion.eulerAngles   = angles;
            property.quaternionValue = quaternion;
        }
示例#20
0
        public override void BeginDraw(BaseMightyMember mightyMember, BaseElementDecoratorAttribute baseAttribute,
                                       Action <BaseMightyMember, SerializedProperty, BaseDrawerAttribute> propertyDrawCallback,
                                       BaseDrawerAttribute drawerAttribute = null)
        {
            var property = mightyMember.Property;

            if (!property.isArray || property.propertyType == SerializedPropertyType.String)
            {
                if (baseAttribute is BeginHorizontalAttribute || baseAttribute is HorizontalAttribute)
                {
                    GUILayout.BeginHorizontal();
                }

                propertyDrawCallback?.Invoke(mightyMember, property, drawerAttribute);
                return;
            }

            if (!EditorDrawUtility.DrawFoldout(property))
            {
                EndDrawHeader(mightyMember, baseAttribute);
                EndDrawArray(mightyMember, baseAttribute);
                return;
            }

            EditorGUI.indentLevel++;
            EditorDrawUtility.DrawArraySizeField(property);

            EditorDrawUtility.DrawArrayBody(property, index =>
            {
                BeginDrawElement(mightyMember, index, baseAttribute);
                propertyDrawCallback?.Invoke(mightyMember, property.GetArrayElementAtIndex(index), drawerAttribute);
                EndDrawElement(mightyMember, index, baseAttribute);
            });

            EditorGUI.indentLevel--;
        }
        public float GetElementHeight(BaseMightyMember mightyMember, int index, BaseDrawerAttribute baseAttribute)
        {
            var element = mightyMember.GetElement(index);

            return(element.propertyType != SerializedPropertyType.String ? 64 : Height(element) + 24);
        }
 public void DrawElement(Rect rect, BaseMightyMember mightyMember, int index, BaseDrawerAttribute baseAttribute) =>
 DrawTextArea(rect, mightyMember.GetElement(index), (ResizableTextAreaAttribute)baseAttribute);
 public void DrawElement(GUIContent label, BaseMightyMember mightyMember, int index, BaseDrawerAttribute baseAttribute) =>
 DrawTextArea(mightyMember.GetElement(index), (ResizableTextAreaAttribute)baseAttribute, label);
        public override void DrawProperty(BaseMightyMember mightyMember, SerializedProperty property, BaseDrawerAttribute baseAttribute)
        {
            if (property.isArray && property.propertyType != SerializedPropertyType.String)
            {
                EditorDrawUtility.DrawArray(property, index => DrawElement(mightyMember, index, baseAttribute));
                return;
            }

            DrawTextArea(property, (ResizableTextAreaAttribute)baseAttribute);
        }
        public override void DrawArray(BaseMightyMember mightyMember, BaseArrayAttribute baseAttribute, IArrayElementDrawer drawer,
                                       BaseDrawerAttribute drawerAttribute)
        {
            var property = mightyMember.Property;

            if (property.isArray)
            {
                var attribute = (ReorderableListAttribute)baseAttribute;

                if (!ArrayCache.Contains(mightyMember))
                {
                    InitDrawer(mightyMember, baseAttribute);
                }
                var(optionInfo, decoratorAttributes, decoratorDrawers) = ArrayCache[mightyMember];

                var option = optionInfo.Value;

                var decoratorLength = decoratorAttributes.Length;

                EditorGUILayout.BeginVertical();

                for (var i = 0; i < decoratorLength; i++)
                {
                    decoratorDrawers[i].BeginDrawArray(mightyMember, decoratorAttributes[i]);
                }

                if (!option.Contains(ArrayOption.HideLabel))
                {
                    if (!option.Contains(ArrayOption.LabelInHeader))
                    {
                        for (var i = 0; i < decoratorLength; i++)
                        {
                            decoratorDrawers[i].BeginDrawHeader(mightyMember, decoratorAttributes[i]);
                        }

                        if (!EditorDrawUtility.DrawFoldout(property))
                        {
                            EditorGUILayout.EndVertical();

                            for (var i = 0; i < decoratorLength; i++)
                            {
                                decoratorDrawers[i].EndDrawHeader(mightyMember, decoratorAttributes[i]);
                            }

                            for (var i = 0; i < decoratorLength; i++)
                            {
                                decoratorDrawers[i].EndDrawArray(mightyMember, decoratorAttributes[i]);
                            }

                            return;
                        }

                        for (var i = 0; i < decoratorLength; i++)
                        {
                            decoratorDrawers[i].EndDrawHeader(mightyMember, decoratorAttributes[i]);
                        }
                    }
                }
                else
                {
                    property.isExpanded = true;
                }

                if (!option.Contains(ArrayOption.DontIndent))
                {
                    m_indentCache[mightyMember] = EditorGUI.indentLevel;
                    EditorDrawUtility.BeginLayoutIndent();
                    EditorGUI.indentLevel = 0;
                    EditorGUILayout.BeginVertical();
                }

                if (!m_reorderableCache.Contains(mightyMember))
                {
                    ReorderableList reorderableList = new ReorderableList(property.serializedObject, property,
                                                                          !option.Contains(ArrayOption.ReadOnly),
                                                                          option.Contains(ArrayOption.LabelInHeader) || !option.Contains(ArrayOption.HideSizeField),
                                                                          attribute.DrawButtons, attribute.DrawButtons)
                    {
                        drawHeaderCallback = rect =>
                        {
                            var drawLabel = option.Contains(ArrayOption.LabelInHeader);

                            if (!drawLabel && option.Contains(ArrayOption.HideSizeField))
                            {
                                return;
                            }

                            for (var i = 0; i < decoratorLength; i++)
                            {
                                rect = decoratorDrawers[i].BeginDrawHeader(rect, mightyMember, decoratorAttributes[i]);
                            }

                            if (!drawLabel)
                            {
                                var enabled = GUI.enabled;
                                GUI.enabled = !option.Contains(ArrayOption.DisableSizeField);
                                EditorDrawUtility.DrawArraySizeField(rect, property);
                                GUI.enabled = enabled;
                            }
                            else
                            {
                                EditorGUI.LabelField(rect, property.displayName);
                            }

                            var newRect = new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight, rect.width, 0);
                            for (var i = 0; i < decoratorLength; i++)
                            {
                                newRect = decoratorDrawers[i].EndDrawHeader(newRect, mightyMember, decoratorAttributes[i]);
                            }
                        },

                        drawElementCallback = (rect, index, isActive, isFocused) =>
                        {
                            rect.y += 2f;

                            var newRect = new Rect(rect.x, rect.y + 21, rect.width, 0);
                            for (var i = 0; i < decoratorLength; i++)
                            {
                                newRect = decoratorDrawers[i].BeginDrawElement(newRect, mightyMember, i, decoratorAttributes[i]);
                            }

                            if (drawer != null)
                            {
                                var height = drawer.GetElementHeight(mightyMember, index, drawerAttribute);
                                drawer.DrawElement(new Rect(rect.x, rect.y, rect.width, height), mightyMember, index, drawerAttribute);
                            }
                            else
                            {
                                EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight),
                                                        property.GetArrayElementAtIndex(index));
                            }

                            for (var i = 0; i < decoratorLength; i++)
                            {
                                newRect = decoratorDrawers[i].EndDrawElement(newRect, mightyMember, i, decoratorAttributes[i]);
                            }
                        },

                        elementHeightCallback = (index) =>
                        {
                            var height = drawer?.GetElementHeight(mightyMember, index, drawerAttribute) ?? 20;

                            for (var i = 0; i < decoratorLength; i++)
                            {
                                height += decoratorDrawers[i].GetElementHeight(mightyMember, i, decoratorAttributes[i]);
                            }

                            return(height);
                        }
                    };

                    m_reorderableCache[mightyMember] = reorderableList;
                }

                m_reorderableCache[mightyMember].DoLayoutList();

                if (!option.Contains(ArrayOption.DontIndent))
                {
                    EditorGUI.indentLevel = m_indentCache[mightyMember];
                    EditorDrawUtility.EndLayoutIndent();
                    EditorGUILayout.EndVertical();
                }

                for (var i = 0; i < decoratorLength; i++)
                {
                    decoratorDrawers[i].EndDrawArray(mightyMember, decoratorAttributes[i]);
                }

                EditorGUILayout.EndVertical();
            }
            else
            {
                EditorDrawUtility.DrawHelpBox($"{baseAttribute.GetType().Name} can be used only on arrays or lists");

                EditorDrawUtility.DrawPropertyField(property);
            }
        }
示例#26
0
        public override void DrawArray(BaseMightyMember mightyMember, BaseArrayAttribute baseAttribute, IArrayElementDrawer drawer,
                                       BaseDrawerAttribute drawerAttribute)
        {
            var property = mightyMember.Property;

            if (!property.isArray)
            {
                EditorDrawUtility.DrawHelpBox($"{typeof(ButtonArrayAttribute).Name} can be used only on arrays or lists");

                EditorDrawUtility.DrawPropertyField(property);
                return;
            }

            if (!ArrayCache.Contains(mightyMember))
            {
                InitDrawer(mightyMember, baseAttribute);
            }
            var(optionInfo, decoratorAttributes, decoratorDrawers) = ArrayCache[mightyMember];

            var option = optionInfo.Value;

            var decoratorLength = decoratorAttributes.Length;

            for (var i = 0; i < decoratorLength; i++)
            {
                decoratorDrawers[i].BeginDrawArray(mightyMember, decoratorAttributes[i]);
            }

            for (var i = 0; i < decoratorLength; i++)
            {
                decoratorDrawers[i].BeginDrawHeader(mightyMember, decoratorAttributes[i]);
            }

            if (!option.Contains(ArrayOption.HideLabel) && !EditorDrawUtility.DrawFoldout(property))
            {
                for (var i = 0; i < decoratorLength; i++)
                {
                    decoratorDrawers[i].EndDrawHeader(mightyMember, decoratorAttributes[i]);
                }

                for (var i = 0; i < decoratorLength; i++)
                {
                    decoratorDrawers[i].EndDrawArray(mightyMember, decoratorAttributes[i]);
                }

                return;
            }

            if (option.Contains(ArrayOption.HideLabel))
            {
                property.isExpanded = true;
            }
            else if (!option.Contains(ArrayOption.DontIndent))
            {
                EditorGUI.indentLevel++;
            }

            for (var i = 0; i < decoratorLength; i++)
            {
                decoratorDrawers[i].EndDrawHeader(mightyMember, decoratorAttributes[i]);
            }


            GUILayout.BeginVertical(GUIStyleUtility.ButtonArray, GUILayout.MinHeight(35));
            var indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

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

                GUILayout.FlexibleSpace();
            }

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

                for (var i = 0; i < decoratorLength; i++)
                {
                    decoratorDrawers[i].BeginDrawElement(mightyMember, index, decoratorAttributes[i]);
                }

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

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

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

                    GUILayout.EndHorizontal();

                    for (var i = 0; i < decoratorLength; i++)
                    {
                        decoratorDrawers[i].EndDrawElement(mightyMember, index, decoratorAttributes[i]);
                    }
                    return;
                }

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

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

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

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

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

                GUILayout.EndHorizontal();

                for (var i = 0; i < decoratorLength; i++)
                {
                    decoratorDrawers[i].EndDrawElement(mightyMember, index, decoratorAttributes[i]);
                }
            });

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

            if (!option.Contains(ArrayOption.HideLabel) && !option.Contains(ArrayOption.DontIndent))
            {
                EditorGUI.indentLevel--;
            }

            for (var i = 0; i < decoratorLength; i++)
            {
                decoratorDrawers[i].EndDrawArray(mightyMember, decoratorAttributes[i]);
            }
        }
示例#27
0
        public override void DrawProperty(BaseMightyMember mightyMember, SerializedProperty property, BaseDrawerAttribute baseAttribute)
        {
            if (property.isArray)
            {
                EditorDrawUtility.DrawArray(property, index => DrawElement(mightyMember, index, baseAttribute));
                return;
            }

            DrawRotation2D(property, baseAttribute);
        }
示例#28
0
 public float GetElementHeight(BaseMightyMember mightyMember, int index, BaseDrawerAttribute baseAttribute) => 16;
示例#29
0
 public void DrawElement(Rect rect, BaseMightyMember mightyMember, int index, BaseDrawerAttribute baseAttribute) =>
 DrawRotation2D(rect, mightyMember.GetElement(index), baseAttribute);
示例#30
0
 public void DrawElement(GUIContent label, BaseMightyMember mightyMember, int index, BaseDrawerAttribute baseAttribute) =>
 DrawRotation2D(mightyMember.GetElement(index), baseAttribute, label);