diff --git a/Assets/NaughtyAttributes/Scripts/Editor/NaughtyInspector.cs b/Assets/NaughtyAttributes/Scripts/Editor/NaughtyInspector.cs index c8b3cd0e..612825a9 100644 --- a/Assets/NaughtyAttributes/Scripts/Editor/NaughtyInspector.cs +++ b/Assets/NaughtyAttributes/Scripts/Editor/NaughtyInspector.cs @@ -144,16 +144,16 @@ protected virtual void DrawSerializedProperties() { continue; } - + NaughtyEditorGUI.BeginBoxGroup_Layout(group.Key); foreach (var naughtyProperty in visibleProperties) { NaughtyEditorGUI.PropertyField_Layout(naughtyProperty, includeChildren: true); } - + NaughtyEditorGUI.EndBoxGroup_Layout(); } - + // Draw foldout serialized properties foreach (var group in _foldoutGroupedSerializedProperty) { @@ -162,12 +162,12 @@ protected virtual void DrawSerializedProperties() { continue; } - + if (!_foldouts.ContainsKey(group.Key)) { _foldouts[group.Key] = new SavedBool($"{target.GetInstanceID()}.{group.Key}", false); } - + _foldouts[group.Key].Value = EditorGUILayout.Foldout(_foldouts[group.Key].Value, group.Key, true); if (_foldouts[group.Key].Value) { diff --git a/Assets/NaughtyAttributes/Scripts/Editor/NaughtyProperty.cs b/Assets/NaughtyAttributes/Scripts/Editor/NaughtyProperty.cs index f71a2bb8..269747b5 100644 --- a/Assets/NaughtyAttributes/Scripts/Editor/NaughtyProperty.cs +++ b/Assets/NaughtyAttributes/Scripts/Editor/NaughtyProperty.cs @@ -5,13 +5,14 @@ namespace NaughtyAttributes.Editor public class NaughtyProperty { public SerializedProperty serializedProperty; + + public LabelAttribute labelAttribute; + public SpecialCaseDrawerAttribute specialCaseDrawerAttribute; + public ShowIfAttributeBase showIfAttribute; - public EnableIfAttributeBase enableIfAttribute; - public ReadOnlyAttribute readOnlyAttribute; - public ValidatorAttribute[] validatorAttributes; } } diff --git a/Assets/NaughtyAttributes/Scripts/Editor/Utility/NaughtyEditorGUI.cs b/Assets/NaughtyAttributes/Scripts/Editor/Utility/NaughtyEditorGUI.cs index 6709f4c1..f15fc7ff 100644 --- a/Assets/NaughtyAttributes/Scripts/Editor/Utility/NaughtyEditorGUI.cs +++ b/Assets/NaughtyAttributes/Scripts/Editor/Utility/NaughtyEditorGUI.cs @@ -67,7 +67,7 @@ private static void PropertyField_Implementation(Rect rect, NaughtyProperty naug using (new EditorGUI.DisabledScope(disabled: !enabled)) { - propertyFieldFunction.Invoke(rect, naughtyProperty, PropertyUtility.GetLabel(naughtyProperty.serializedProperty), includeChildren); + propertyFieldFunction.Invoke(rect, naughtyProperty, PropertyUtility.GetLabel(naughtyProperty.labelAttribute, naughtyProperty.serializedProperty), includeChildren); } // Call OnValueChanged callbacks diff --git a/Assets/NaughtyAttributes/Scripts/Editor/Utility/PropertyUtility.cs b/Assets/NaughtyAttributes/Scripts/Editor/Utility/PropertyUtility.cs index 9337afe0..4f7dc6f1 100644 --- a/Assets/NaughtyAttributes/Scripts/Editor/Utility/PropertyUtility.cs +++ b/Assets/NaughtyAttributes/Scripts/Editor/Utility/PropertyUtility.cs @@ -31,14 +31,16 @@ public static NaughtyProperty CreateNaughtyProperty(SerializedProperty serialize NaughtyProperty naughtyProperty = new NaughtyProperty(); naughtyProperty.serializedProperty = serializedProperty; - naughtyProperty.readOnlyAttribute = PropertyUtility.GetAttribute(naughtyProperty.serializedProperty); - naughtyProperty.enableIfAttribute = PropertyUtility.GetAttribute(naughtyProperty.serializedProperty); + naughtyProperty.readOnlyAttribute = PropertyUtility.GetAttribute(serializedProperty); + naughtyProperty.enableIfAttribute = PropertyUtility.GetAttribute(serializedProperty); - naughtyProperty.showIfAttribute = PropertyUtility.GetAttribute(naughtyProperty.serializedProperty); - naughtyProperty.validatorAttributes = PropertyUtility.GetAttributes(naughtyProperty.serializedProperty); + naughtyProperty.showIfAttribute = PropertyUtility.GetAttribute(serializedProperty); + naughtyProperty.validatorAttributes = PropertyUtility.GetAttributes(serializedProperty); + naughtyProperty.labelAttribute = PropertyUtility.GetAttribute(serializedProperty); + naughtyProperty.specialCaseDrawerAttribute = - PropertyUtility.GetAttribute(naughtyProperty.serializedProperty); + PropertyUtility.GetAttribute(serializedProperty); return naughtyProperty; } @@ -46,6 +48,11 @@ public static NaughtyProperty CreateNaughtyProperty(SerializedProperty serialize public static GUIContent GetLabel(SerializedProperty property) { LabelAttribute labelAttribute = GetAttribute(property); + return GetLabel(labelAttribute, property); + } + + public static GUIContent GetLabel(LabelAttribute labelAttribute, SerializedProperty property) + { string labelText = (labelAttribute == null) ? property.displayName : labelAttribute.Label; @@ -155,7 +162,7 @@ public static bool IsVisible(ShowIfAttributeBase showIfAttribute, SerializedProp { return true; } - + object target = GetTargetObjectWithProperty(property); // deal with enum conditions