If you'd like to see the inspector values updated in the Ork Handler (in event, control blocked, etc.) and you don't want to select/deselect the inspector or write the values out to a UI or your console, here's a fun solution.

This is purely for convenient debugging purposes. Updating the inspector like this isn't performant (though at least it isn't being called every frame, just every 0.1 seconds). However, it definitely saves a lot of headaches trying to know what's going on at all times.

I made it so the code only executes in the unity editor, but you could always disable or remove the script when you're done with it too.

Make a new C# script named orkHandlerUpdater.cs and slap it on a starting gameobject that doesn't get destroyed.

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
}


and there you go! This method could be utilized for other stuff too like the player combatant, a grid, etc. Just change out the gameobject and component and you're good.

I don't know about y'all, but this is basically a debugging lifesaver for me.
Post edited by braytendo on
  • The handler's inspector also automatically updates when it gets some input, e.g. moving the mouse over it or clicking on it :)
    That's also valid for the combatant component on your spawned combatants.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I did notice that, but I'm greedy and I want to see the updates right now immediately. :P

    And you laid the variables out so nicely in the handler, it'd be a shame to chuck it all in the console.
Sign In or Register to comment.