Register Event on Inventory Open/Close

maaxiim

Member
Hi,
I have a situation with the UIS inventory menu when I open the menu, it does not unlock and show the cursor. I have quite a few changes locally including adding a radial where I show/hide the cursor when it is activated. I suspect that is what is causing the UIS inventory to no longer show the cursor when it's open.
I was hoping I could call RegisterEvent against EventNames.c_GameObject_OnOpen_UIMenuPanel_Bool like this:

C#:
void Awake() {
    EventHandler.RegisterEvent<DisplayMenuPanel, bool>(m_PanelOwner, EventNames.c_GameObject_OnOpen_UIMenuPanel_Bool, MenuWasOpened);
}
private void MenuWasOpened(DisplayMenuPanel panel, bool isOpen)
{
    Debug.Log("cursor on open, visible: " + isOpen);
    Cursor.visible = isOpen;
    Cursor.lockState = isOpen ? CursorLockMode.None : CursorLockMode.Locked;
}
And dragging the InventoryMenu->MainMenu game object from my UI in to the m_PanelOwner field.
I never see any debug log messages related to this when i open/close my menu so I'm guessing maybe I am using the wrong panel object?
Any help or ideas about a better way to achieve this, would be appreciated!
Thanks
 
I just found the solution. I dragged my character in to the Panel Owner field of the Display Panel Manager and I started to see the cursor again. I can remove those event handlers I think
 
Yes you did well setting the character as your panel owner. I'm glad you found the solution to your issue
 
Top