Made serilaized static values be set
This commit is contained in:
@@ -46,15 +46,6 @@ 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,9 +2,6 @@
|
|||||||
|
|
||||||
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,9 +1,8 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System;
|
using System;
|
||||||
using PashaBibko.Pacore.DevTools;
|
using PashaBibko.Pacore.Data;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace PashaBibko.Pacore
|
namespace PashaBibko.Pacore
|
||||||
@@ -54,6 +53,10 @@ namespace PashaBibko.Pacore
|
|||||||
AttributeCache[type].Add(current);
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ namespace PashaBibko.Pacore.Data
|
|||||||
public static string FullResourcesPath => Path.Join(Application.dataPath, BASE_PATH);
|
public static string FullResourcesPath => Path.Join(Application.dataPath, BASE_PATH);
|
||||||
public static string ResourcesPath => Path.Join("Assets", BASE_PATH);
|
public static string ResourcesPath => Path.Join("Assets", BASE_PATH);
|
||||||
|
|
||||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
|
public static void LoadAndApplyStaticValues()
|
||||||
private static void LoadAndApplyStaticValues()
|
|
||||||
{
|
{
|
||||||
/* Loads the static values from the serialized file */
|
/* Loads the static values from the serialized file */
|
||||||
string filename = Path.Join(PATH_FROM_RESOURCES, "StaticFieldValues");
|
string filename = Path.Join(PATH_FROM_RESOURCES, "StaticFieldValues");
|
||||||
|
|||||||
@@ -35,8 +35,12 @@ namespace PashaBibko.Pacore.Threading
|
|||||||
|
|
||||||
Instance = this;
|
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 QueueMultistep(IEnumerator routine) => MainThreadMultistepQueue.Enqueue(routine);
|
||||||
public static void QueueImmediate(Action action) => MainThreadImmediateQueue.Enqueue(action);
|
public static void QueueImmediate(Action action) => MainThreadImmediateQueue.Enqueue(action);
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
using PashaBibko.Pacore.Attributes;
|
using PashaBibko.Pacore.Attributes;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
[CreateInstanceOnStart, AllowStaticInspectorFields]
|
[CreateInstanceOnStart] public class TestMonoBehaviour : MonoBehaviour
|
||||||
public class TestMonoBehaviour : MonoBehaviour
|
|
||||||
{
|
{
|
||||||
public int TestValue;
|
public int TestValue;
|
||||||
|
|
||||||
[StaticInspectorField] private static string StaticText;
|
[StaticInspectorField] private static string StaticText;
|
||||||
[StaticInspectorField] private static string OtherStaticText;
|
[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))]
|
[InspectorCallable(nameof(PrintStaticFields))]
|
||||||
public void PrintStaticFields()
|
public void PrintStaticFields()
|
||||||
{
|
{
|
||||||
Debug.Log
|
Debug.Log
|
||||||
(
|
(
|
||||||
$"{nameof(TestValue)}: [{TestValue}] " +
|
$"{nameof(StaticInt)}: [{StaticInt}] " +
|
||||||
|
$"{nameof(OtherStaticInt)}: [{OtherStaticInt}] " +
|
||||||
$"{nameof(StaticText)}: [{StaticText}] " +
|
$"{nameof(StaticText)}: [{StaticText}] " +
|
||||||
$"{nameof(OtherStaticText)}: [{OtherStaticText}]"
|
$"{nameof(OtherStaticText)}: [{OtherStaticText}]"
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user