Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnityContent: support multiple event handlers #110

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

stefanb2
Copy link

  • remove IUnityEvent
  • add UnityEvents class
    • AddEventListener() adds a callback for an event name
    • DispatchEvent() calls all callbacks for an event name
    • errors from event handlers are ignored
    • the first event handler returning truthy aborts dispatch
  • UnityContent
    • add UnityEvents class property for global events
    • only install one callback per global event name
    • add UnityEvents instance property for instance events
  • some other minor fixes I noticed while developing the code

Fixes #109

Fixes building & testing on case-sensitive file system.
- remove IUnityEvent
- add UnityEvents class
  * AddEventListener() adds a callback for an event name
  * DispatchEvent() calls all callbacks for an event name
  * errors from event handlers are ignored
  * the first event handler returning truthy aborts dispatch
- UnityContent
  * add UnityEvents class property for global events
  * only install one callback per global event name
  * add UnityEvents instance property for instance events

Fixes jeffreylanters#109
Events which are dispatched via triggerUnityEvents() are instance
specific events that do not need a global event handler attached to
ReactUnityWebGL object. All other event names are assumed to be global
ones.

Fixes jeffreylanters#109
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Event handler for Unity Events is global
1 participant