So, you want to trigger a script or an event every time the save menu opens, or maybe when it closes, or when some specific Ork framework GUI Box is open...

...but you can only check if a menu screen is open, not a GUI box, right?

Wrong! You just gotta think outside the box! (Ba dum tss)

Under Menu > GUI Boxes > The box you want to track:

Make sure Show Box is checked under Content Box Settings.

Now go to the Override default settings section, then GUI Skins. Choose "Own skins" and under the Content Box Prefab, you're going to add a prefab (or update your existing prefab) with a script containing this code:

void OnTransformParentChanged()
{
if (transform.parent.name != "UIPool")
{
//code to run when the GUI Box opens
}
else
{
//code to run when the GUI Box closes
}
}

So long as you're using the new UI, your script is at the top of the prefab hierarchy, and GIL continues to put unused UI content in a UIPool, this should work. At least so far it has worked for me.

Now you can trigger a global event with ORK.GlobalEvents.Get(index).Call(); or run whatever other script you want when the GUI box appears or closes!

It might be a bit hackish, but sometimes you gotta do what you gotta do to get the job done. :P
  • You can also use the OnEnable and OnDisable functions of a component on the prefab :)
    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!
Sign In or Register to comment.