diff --git a/Assets/Pacore/Editor/Drawers/MonoBehaviourDrawer.cs b/Assets/Pacore/Editor/Drawers/MonoBehaviourDrawer.cs index c82205b..9f6d1ac 100644 --- a/Assets/Pacore/Editor/Drawers/MonoBehaviourDrawer.cs +++ b/Assets/Pacore/Editor/Drawers/MonoBehaviourDrawer.cs @@ -46,15 +46,6 @@ 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 e53c68a..1c4eb4b 100644 --- a/Assets/Pacore/Runtime/Attributes/StaticInspectorField.cs +++ b/Assets/Pacore/Runtime/Attributes/StaticInspectorField.cs @@ -2,9 +2,6 @@ namespace PashaBibko.Pacore.Attributes { - [AttributeUsage(validOn: AttributeTargets.Class)] - public class AllowStaticInspectorFieldsAttribute : Attribute { } - [AttributeUsage(validOn: AttributeTargets.Field)] public class StaticInspectorFieldAttribute : Attribute { } } \ No newline at end of file diff --git a/Assets/Pacore/Runtime/ClassAttributeCache.cs b/Assets/Pacore/Runtime/ClassAttributeCache.cs index 52c97b2..a4043db 100644 --- a/Assets/Pacore/Runtime/ClassAttributeCache.cs +++ b/Assets/Pacore/Runtime/ClassAttributeCache.cs @@ -1,9 +1,8 @@ using System.Collections.ObjectModel; using System.Collections.Generic; -using System.Reflection; using System.Linq; using System; -using PashaBibko.Pacore.DevTools; +using PashaBibko.Pacore.Data; using UnityEngine; namespace PashaBibko.Pacore @@ -54,6 +53,10 @@ namespace PashaBibko.Pacore AttributeCache[type].Add(current); } } + + /* Initializes PacoreDataLoader as it requires this to have been loaded first */ + // TODO: Add a way for this to trigger an event that can be run by other scripts dynamically + PacoreDataLoader.LoadAndApplyStaticValues(); } } } diff --git a/Assets/Pacore/Runtime/Data/DataLoader.cs b/Assets/Pacore/Runtime/Data/DataLoader.cs index d996d34..81c4d1a 100644 --- a/Assets/Pacore/Runtime/Data/DataLoader.cs +++ b/Assets/Pacore/Runtime/Data/DataLoader.cs @@ -14,8 +14,7 @@ namespace PashaBibko.Pacore.Data public static string FullResourcesPath => Path.Join(Application.dataPath, BASE_PATH); public static string ResourcesPath => Path.Join("Assets", BASE_PATH); - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] - private static void LoadAndApplyStaticValues() + public static void LoadAndApplyStaticValues() { /* Loads the static values from the serialized file */ string filename = Path.Join(PATH_FROM_RESOURCES, "StaticFieldValues"); diff --git a/Assets/Pacore/Runtime/Threading/ThreadDispatcher.cs b/Assets/Pacore/Runtime/Threading/ThreadDispatcher.cs index 849d596..a9f91b6 100644 --- a/Assets/Pacore/Runtime/Threading/ThreadDispatcher.cs +++ b/Assets/Pacore/Runtime/Threading/ThreadDispatcher.cs @@ -35,8 +35,12 @@ namespace PashaBibko.Pacore.Threading Instance = this; } - - + + private void OnDestroy() + { + Instance = null; // Allows the Dispatcher to be destroyed + } + public static void QueueMultistep(IEnumerator routine) => MainThreadMultistepQueue.Enqueue(routine); public static void QueueImmediate(Action action) => MainThreadImmediateQueue.Enqueue(action); diff --git a/Assets/TestMonoBehaviour.cs b/Assets/TestMonoBehaviour.cs index bf31391..fefe8b3 100644 --- a/Assets/TestMonoBehaviour.cs +++ b/Assets/TestMonoBehaviour.cs @@ -1,21 +1,22 @@ using PashaBibko.Pacore.Attributes; using UnityEngine; -[CreateInstanceOnStart, AllowStaticInspectorFields] -public class TestMonoBehaviour : MonoBehaviour +[CreateInstanceOnStart] public class TestMonoBehaviour : MonoBehaviour { public int TestValue; [StaticInspectorField] private static string StaticText; [StaticInspectorField] private static string OtherStaticText; - [StaticInspectorField] private static int StaticInt; + [StaticInspectorField] private static int StaticInt = 0; + [StaticInspectorField] private static int OtherStaticInt = 0; [InspectorCallable(nameof(PrintStaticFields))] public void PrintStaticFields() { Debug.Log ( - $"{nameof(TestValue)}: [{TestValue}] " + + $"{nameof(StaticInt)}: [{StaticInt}] " + + $"{nameof(OtherStaticInt)}: [{OtherStaticInt}] " + $"{nameof(StaticText)}: [{StaticText}] " + $"{nameof(OtherStaticText)}: [{OtherStaticText}]" );