I need to subscribe some action to my xbox controller buttons when a UI panel is onFront, and clear all subscriptions when it’s not onFront.
It’s quite annoying to do this by -= everywhere, could be negligent some times and thus make mistakes.
Could Unity just add a ClearAllEventHandlers() or GetInvocationList() function to InputAction class to make this easier? (you can not do this out side the class which define the event)
Or anyone has a better way to deal with the console button controlling UIs, for example , press x to toggle an infomation window display or not.
Well…I was already did this. The problem is, for example, when two UI panels are stacking showing, and both of them response button x to print some log, but this is not correct, just the TOP one should do this.
I found a way to encapsulate the c# Events to UnityEvents for a easy RemoveAll: