- Home /
How to unsubscribe from InputSystem event properly
     private void Awake()
     {
         Controls.InputMap.Player.Charge.performed += Charge;
         Controls.InputMap.Player.Teleport.performed += Teleport;
     }
 
     private void Teleport(InputAction.CallbackContext context) => StartCoroutine(Teleport());
     private void Charge(InputAction.CallbackContext context) => StartCoroutine(Charge());
 
 
     private void OnDestroy()
     {
         print("destroyed");
         Controls.InputMap.Player.Charge.performed -= Charge;
         Controls.InputMap.Player.Teleport.performed -= Teleport;
     }
Every time I restart scene the console is full of MissingReferenceExceptions referenced to the InputSystem callbacks.

Despite the fact I unsubscribe from this event in OnDestroy. How do I properly unsubscribe from this event?
               Comment
              
 
               
              Answer by MorrowporoSpm · May 17 at 02:48 PM
This link helped me:
https://forum.unity.com/threads/how-to-remove-and-inputaction-phase-callback.894601/
 private void doSomething(CallbackContext ctx)
 {
 // do the thing
 }
 
 //register
 action.started += doSomething;
 //unregsiter
 action.started -= doSomething;
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                