Seems like no way to clear all event subscriptions of an InputAction

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.

Create separate ActionMaps for game play and UI and turn on and off (enable) depending which one is that you need at the moment.

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:

        public class InputActionEvent : UnityEvent<InputAction.CallbackContext> { }
        protected InputActionEvent onShoulderButtonPerformed = new InputActionEvent();
        protected InputActionEvent onShoulderButtonCanceled = new InputActionEvent();

        void OnShoulderButtonPerformed( InputAction.CallbackContext ctx ) { onShoulderButtonPerformed.Invoke( ctx ); }
        void OnShoulderButtonCanceled( InputAction.CallbackContext ctx ) { onShoulderButtonCanceled.Invoke( ctx ); }
      
        /// <summary>
        /// when panel OnTop
        /// </summary>      
        protected void BindInputActionEvent() {
            Debug.Log( $"{transform.name} :  BindInputActionEvent" );
            GM.InputAction_UI_changePageShoulder.performed += OnShoulderButtonPerformed;
            GM.InputAction_UI_changePageShoulder.canceled += OnShoulderButtonCanceled;
        }
        /// <summary>
        /// When panel NotOnTop or Closed
        /// </summary>
        protected void UnBindInputActionEvent() {
            Debug.Log( $"{transform.name} :  UnBindInputActionEvent" );
            GM.InputAction_UI_changePageShoulder.performed -= OnShoulderButtonPerformed;
            GM.InputAction_UI_changePageShoulder.canceled -= OnShoulderButtonCanceled;
        }
        /// <summary>
        /// when panel OnInstantiate
        /// </summary>
        protected void InitButtonEvent() {
            Debug.Log( $"{transform.name} :  InitButtonEvent" );
        }
        /// <summary>
        /// when panel OnDestroy
        /// </summary>
        protected void RemoveAllListeners() {
            Debug.Log( $"{transform.name} :  ClearAllEvents" );
            onShoulderButtonPerformed.RemoveAllListeners();
            onShoulderButtonCanceled.RemoveAllListeners();
        }

Put these code in BaseUIPanel class to avoid -= everywhere things, just no brain AddListener to the InputActionEvents, happy as hell.