Search Unity

Input System, .cancelled callbacks not working

Discussion in 'Input System' started by roman_sedition, May 14, 2019.

  1. roman_sedition

    roman_sedition

    Joined:
    Nov 6, 2016
    Posts:
    13
    I can't seem to get events to fire from .cancelled callbacks when I use the InputActions assets.


    https://imgur.com/gORVsto

    This is the code.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Experimental.Input;
    5.  
    6. public class TestMe : MonoBehaviour
    7. {
    8.     [SerializeField]
    9.     private MyActions foo;
    10.  
    11.     [SerializeField] InputAction up;
    12.  
    13.     private void Awake()
    14.     {
    15.         foo = new MyActions();
    16.         foo.Player.Wicked.performed += context => Debug.Log("performed, pressing 'space'");
    17.         foo.Player.Wicked.cancelled += context => Debug.Log("cancelled, released 'space'");
    18.  
    19.         up.continuous = true;
    20.         up.performed += context => Debug.Log("performed pressing 't'");
    21.         up.cancelled += context => Debug.Log("cancelled, released 't'");
    22.  
    23.     }
    24.  
    25.     private void OnEnable()
    26.     {
    27.         foo.Enable();
    28.         up.Enable();
    29.     }
    30.  
    31.     private void OnDisable()
    32.     {
    33.         foo.Disable();
    34.         up.Disable();
    35.     }
    36. }
    37.  
    But I can get .cancelled callbacks from InputActions that I assign in the inspector window.


    https://imgur.com/LacJqsn


    https://imgur.com/zx2s5va

    I am using Unity 2019.1.1f1 and Input System package 0.2.8
     
    Last edited: May 14, 2019
  2. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Change "cancelled" to "canceled" and you should be right. There was a spelling change from International to US English.