Simpler Event Registration - IUIEventHandler, vs. 6 UnityEvents. #265
najak3d
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Rather than forcing the more tedious (and computationally/memory intensive) method of registering and deregistering for each event PER control -- i.e. Click, Hovered, Unhovered, Press, Release, Cancel.
Instead each UIControl should have one field, "IUEventHandler EventHandler", as follows:
Or to make this interface easier to implement, just have 1 main method, as follows:
Then, hooking up Controls can be "automated" (set in the Prefab itself) or set manually with a single C# line of code.
Then you can decide whether or not have a shared-singleton handler - which acts like a centralized event dispatcher -- OR you can assign individual Handlers to any control, that is specific to that Control, or that Control class/type.
IMO, this would be MUCH better than having 6 separate event handler methods for each control that have to individually be Registered and Removed for each Control Enable/Disable.
Beta Was this translation helpful? Give feedback.
All reactions