using UnityEngine;
using ORKFramework;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class orkHandlerUpdater : MonoBehaviour
{
#if UNITY_EDITOR
private ORKHandler OrkHandler;
private bool refreshInspectorRequested = false;
private float timeSinceLastInspectorUpdate = 0f;
private float inspectorUpdateInterval = 0.1f; // Set the desired update interval in seconds.
private void Start()
{
GameObject Ork = GameObject.Find("_ORK");
if (Ork != null)
{
OrkHandler = Ork.GetComponent<ORKHandler>();
}
}
private void Update()
{
// Request an Inspector refresh
RequestInspectorRefresh();
}
private void RequestInspectorRefresh()
{
if (OrkHandler != null)
{
timeSinceLastInspectorUpdate += Time.deltaTime;
if (timeSinceLastInspectorUpdate >= inspectorUpdateInterval)
{
timeSinceLastInspectorUpdate = 0f;
// Request the Inspector to refresh.
// This will make the changes visible in the Inspector.
refreshInspectorRequested = true;
EditorApplication.update += RefreshInspector;
}
}
}
private void RefreshInspector()
{
if (refreshInspectorRequested && OrkHandler != null)
{
refreshInspectorRequested = false;
// Use the SetDirty method to refresh the Inspector.
UnityEditor.EditorUtility.SetDirty(OrkHandler.gameObject);
}
}
#endif
}
It looks like you're new here. If you want to get involved, click one of these buttons!
That's also valid for the combatant component on your spawned combatants.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
And you laid the variables out so nicely in the handler, it'd be a shame to chuck it all in the console.