Eventlistener i.e. OnSessionBegin #73
-
Linking my public methods to the event slots in the UXF inspector tab 'events' works fine, but I'd like to define the event listener in code so I won't need the inspector for (all) of the methods I want to be called. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
it should just work the same way as a unity event: https://docs.unity3d.com/ScriptReference/Events.UnityEvent.AddListener.html However they need to take the Session as an argument e.g. void Start()
{
session.onSessionBegin.AddListener(DoStuff);
}
void DoStuff(Session mySession)
{
Debug.Log("Hello");
} or even void Start()
{
session.onSessionBegin.AddListener((s) => Debug.Log("Hello"));
} Note though, these listeners will be added, but will not show up the UI. They will be removed when you exit play mode. |
Beta Was this translation helpful? Give feedback.
it should just work the same way as a unity event:
https://docs.unity3d.com/ScriptReference/Events.UnityEvent.AddListener.html
However they need to take the Session as an argument e.g.
or even
Note though, these listeners will be added, but will not show up the UI. They will be removed when you exit play mode.