diff --git a/Editor/ReorderableArrayInspector.cs b/Editor/ReorderableArrayInspector.cs index 73fc384..0dfd904 100644 --- a/Editor/ReorderableArrayInspector.cs +++ b/Editor/ReorderableArrayInspector.cs @@ -162,7 +162,17 @@ public bool DoLayoutProperty(SerializedProperty property) return false; // Draw the header - string headerText = string.Format("{0} [{1}]", property.displayName, property.arraySize); + object[] attr = property.GetAttributes(); + string displayName = ""; + if (attr != null && attr.Length == 1) + { + ReorderableAttribute arrayAttr = (ReorderableAttribute)attr[0]; + if (arrayAttr != null) + { + displayName = arrayAttr.DisplayName; + } + } + string headerText = string.Format("{0} [{1}]", string.IsNullOrEmpty(displayName) ? property.displayName : displayName, property.arraySize); EditorGUILayout.PropertyField(property, new GUIContent(headerText), false); // Save header rect for handling drag and drop diff --git a/Editor/SerializedPropExtension.cs b/Editor/SerializedPropExtension.cs index 67a36ab..2e0c6aa 100644 --- a/Editor/SerializedPropExtension.cs +++ b/Editor/SerializedPropExtension.cs @@ -267,7 +267,16 @@ public static object[] GetAttributes(this SerializedProperty prop) | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public; - FieldInfo field = objType.GetField(prop.name, bindingFlags); + FieldInfo field = null; + while (objType != null) + { + field = objType.GetField(prop.name, bindingFlags); + if (field != null) + { + break; + } + objType = objType.BaseType; + } if (field != null) return field.GetCustomAttributes(attrType, true); return new object[0]; diff --git a/ReorderableAttribute.cs b/ReorderableAttribute.cs index f54eae1..016f56f 100644 --- a/ReorderableAttribute.cs +++ b/ReorderableAttribute.cs @@ -29,6 +29,7 @@ namespace SubjectNerd.Utilities /// public class ReorderableAttribute : PropertyAttribute { + public string DisplayName { get; protected set; } public string ElementHeader { get; protected set; } public bool HeaderZeroIndex { get; protected set; } public bool ElementSingleLine { get; protected set; } @@ -55,5 +56,13 @@ public ReorderableAttribute(string headerString = "", bool isZeroIndex = true, b HeaderZeroIndex = isZeroIndex; ElementSingleLine = isSingleLine; } + + public ReorderableAttribute(string displayName = "", string headerString = "", bool isZeroIndex = true, bool isSingleLine = false) + { + DisplayName = displayName; + ElementHeader = headerString; + HeaderZeroIndex = isZeroIndex; + ElementSingleLine = isSingleLine; + } } }