Made classes require AllowStaticInspectorFields for static inspector fields

This commit is contained in:
2026-01-26 15:39:09 +00:00
parent e286ea971d
commit edc272945c
3 changed files with 16 additions and 4 deletions

View File

@@ -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);

View File

@@ -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 { }
{
}
} }

View File

@@ -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;