Using the built in EventNames

Hi,
I need to receive a message that the Inventory Panel has been opened or closed.
Looking through EventNames.cs, I found this:
public const string c_GameObject_OnPanelOpenClose_PanelEventData = "GameObject_OnPanelOpenClose_PanelEventData";

And in the documentation there is something similar to this:
EventHandler.RegisterEvent<ItemInfo, ItemStack>(myObject, EventNames.c_GameObject_OnPanelOpenClose_PanelEventData, OnOpenPanel);

What I'm not sure about is what I should be using for the ItemInfo and ItemStack types.

How should I approach this?
 
Hi,

You've misunderstood how the event system works
This page should clarify a few things.

the types between the <> are the parameters the event will pass to your listening function. They must match exactly what the event executes.

The event c_GameObject_OnPanelOpenClose_PanelEventData does not use ItemInfo or ItemStack as parameters. it uses "PanelEventData". so you'll want to listen to it with

Code:
EventHandler.RegisterEvent<PanelEventData>(thePanelOwner, EventNames.c_GameObject_OnPanelOpenClose_PanelEventData, OnOpenPanelorClose);

You can see an example on this page:

although the event name is different... so it might be out of date, I'll have to double check
 
No need to double check, this works just fine, thanks a lot.
So I fished around a bit, and just to prevent me from posting more event questions, is there a script where I can find the UIS events and their parameters?
 
The name of the event usually indicates the parameter used.
c_GameObject_OnPanelOpenClose_PanelEventData
But not always.

When you aren't sure, the best is to do a Ctrl+Shift+F to search your entire code base for the event
(example c_GameObject_OnPanelOpenClose_PanelEventData)
This way you'll find where it is executed and or registered. And from there you can find what parameter type should be used
 
Top