Made classes require AllowStaticInspectorFields for static inspector fields
This commit is contained in:
@@ -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<AllowStaticInspectorFieldsAttribute>();
|
||||
if (attr == null)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Static Fields (disabled for class)", EditorStyles.boldLabel);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
StaticInspectorFieldCache.FieldData[] fields
|
||||
= StaticInspectorFieldCache.GetAllFieldsOfType(type);
|
||||
|
||||
|
||||
@@ -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 { }
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
using PashaBibko.Pacore.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateInstanceOnStart] public class TestMonoBehaviour : MonoBehaviour
|
||||
[CreateInstanceOnStart, AllowStaticInspectorFields]
|
||||
public class TestMonoBehaviour : MonoBehaviour
|
||||
{
|
||||
public int TestValue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user