diff --git a/Assets/Pacore/Editor/Drawers/MonoBehaviourDrawer.cs b/Assets/Pacore/Editor/Drawers/MonoBehaviourDrawer.cs index a114091..c82205b 100644 --- a/Assets/Pacore/Editor/Drawers/MonoBehaviourDrawer.cs +++ b/Assets/Pacore/Editor/Drawers/MonoBehaviourDrawer.cs @@ -3,6 +3,7 @@ using UnityEditor; using UnityEngine; using System; using System.Reflection; +using PashaBibko.Pacore.Attributes; using PashaBibko.Pacore.Editor.Data; using Object = UnityEngine.Object; @@ -45,6 +46,15 @@ namespace PashaBibko.Pacore.Editor.Drawers public static void DrawStaticFields(Object target) { Type type = target.GetType(); + AllowStaticInspectorFieldsAttribute attr = type.GetCustomAttribute(); + if (attr == null) + { + EditorGUILayout.Space(); + EditorGUILayout.LabelField("Static Fields (disabled for class)", EditorStyles.boldLabel); + + return; + } + StaticInspectorFieldCache.FieldData[] fields = StaticInspectorFieldCache.GetAllFieldsOfType(type); diff --git a/Assets/Pacore/Runtime/Attributes/StaticInspectorField.cs b/Assets/Pacore/Runtime/Attributes/StaticInspectorField.cs index 3146e73..e53c68a 100644 --- a/Assets/Pacore/Runtime/Attributes/StaticInspectorField.cs +++ b/Assets/Pacore/Runtime/Attributes/StaticInspectorField.cs @@ -2,8 +2,9 @@ namespace PashaBibko.Pacore.Attributes { + [AttributeUsage(validOn: AttributeTargets.Class)] + public class AllowStaticInspectorFieldsAttribute : Attribute { } + [AttributeUsage(validOn: AttributeTargets.Field)] - public class StaticInspectorFieldAttribute : Attribute - { - } + public class StaticInspectorFieldAttribute : Attribute { } } \ No newline at end of file diff --git a/Assets/TestMonoBehaviour.cs b/Assets/TestMonoBehaviour.cs index c7d76c9..bf31391 100644 --- a/Assets/TestMonoBehaviour.cs +++ b/Assets/TestMonoBehaviour.cs @@ -1,7 +1,8 @@ using PashaBibko.Pacore.Attributes; using UnityEngine; -[CreateInstanceOnStart] public class TestMonoBehaviour : MonoBehaviour +[CreateInstanceOnStart, AllowStaticInspectorFields] +public class TestMonoBehaviour : MonoBehaviour { public int TestValue;