Eventlistener i.e. OnSessionBegin #73
Answered
by
jackbrookes
thefirstfloor
asked this question in
Q&A
|
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. |
Answered by
jackbrookes
Apr 19, 2021
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. |
1 reply
Answer selected by
thefirstfloor
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.