Made classes require AllowStaticInspectorFields for static inspector fields
This commit is contained in:
@@ -3,6 +3,7 @@ using UnityEditor;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using PashaBibko.Pacore.Attributes;
|
||||||
using PashaBibko.Pacore.Editor.Data;
|
using PashaBibko.Pacore.Editor.Data;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
@@ -45,6 +46,15 @@ namespace PashaBibko.Pacore.Editor.Drawers
|
|||||||
public static void DrawStaticFields(Object target)
|
public static void DrawStaticFields(Object target)
|
||||||
{
|
{
|
||||||
Type type = target.GetType();
|
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.FieldData[] fields
|
||||||
= StaticInspectorFieldCache.GetAllFieldsOfType(type);
|
= StaticInspectorFieldCache.GetAllFieldsOfType(type);
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
namespace PashaBibko.Pacore.Attributes
|
namespace PashaBibko.Pacore.Attributes
|
||||||
{
|
{
|
||||||
|
[AttributeUsage(validOn: AttributeTargets.Class)]
|
||||||
|
public class AllowStaticInspectorFieldsAttribute : Attribute { }
|
||||||
|
|
||||||
[AttributeUsage(validOn: AttributeTargets.Field)]
|
[AttributeUsage(validOn: AttributeTargets.Field)]
|
||||||
public class StaticInspectorFieldAttribute : Attribute
|
public class StaticInspectorFieldAttribute : Attribute { }
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
using PashaBibko.Pacore.Attributes;
|
using PashaBibko.Pacore.Attributes;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
[CreateInstanceOnStart] public class TestMonoBehaviour : MonoBehaviour
|
[CreateInstanceOnStart, AllowStaticInspectorFields]
|
||||||
|
public class TestMonoBehaviour : MonoBehaviour
|
||||||
{
|
{
|
||||||
public int TestValue;
|
public int TestValue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user