- 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?
без-имени-1.png
(36.6 kB)
Comment