I think the top menu Transform is
An alternative solution to OnGUI - there's a generic way to handle cases where you need a callback for a gameobject being enabled or disabled (among other possible MonoBehaviour event functions):
That can be added as a component to the topWorldUI gameobject, and you can then disable the canvas when the topWorldUI gameobject is enabled and enable when it is disabled:
SuperController.singleton.topWorldUI, so you can probably just check if its gameObject is activeSelf.An alternative solution to OnGUI - there's a generic way to handle cases where you need a callback for a gameobject being enabled or disabled (among other possible MonoBehaviour event functions):
C#:
class UnityEventsListener : MonoBehaviour
{
public Action enabledHandlers;
public Action disabledHandlers;
void OnEnable()
{
enabledHandlers?.Invoke();
}
void OnDisable()
{
disabledHandlers?.Invoke();
}
}
That can be added as a component to the topWorldUI gameobject, and you can then disable the canvas when the topWorldUI gameobject is enabled and enable when it is disabled:
C#:
Canvas _myCanvas;
UnityEventsListener _topWorldUIListener;
public override void Init()
{
_topWorldUIListener = SuperController.singleton.topWorldUI.gameObject.AddComponent<UnityEventsListener>();
_topWorldUIListener.enabledHandlers += OnTopWorldUIEnabled;
_topWorldUIListener.disabledHandlers += OnTopWorldUIDisabled;
}
void OnTopWorldUIEnabled()
{
SuperController.LogMessage("[INF] I'm here [TopWorldUI] ... ");
if(this.enabled) // if the plugin is enabled
{
_myCanvas.enabled = false;
}
}
void OnTopWorldUIDisabled()
{
SuperController.LogMessage("[INF] [TopWorldUI] closed... ");
if(this.enabled) // if the plugin is enabled
{
_myCanvas.enabled = true;
}
}
void OnDestroy()
{
if(_topWorldUIListener != null)
{
UnityEngine.Object.Destroy(_topWorldUIListener);
}
}