Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

[Solved] Can not drag action reference in inspector for New Input System

Discussion in 'Input System' started by Tymianek, Jun 15, 2021.

  1. Tymianek

    Tymianek

    Joined:
    May 16, 2015
    Posts:
    97
    Hey
    I want to reference an InputAction in my code.

    I have a CastSpell1 action defined in the new Input System
    upload_2021-6-15_2-33-32.png
    I have a simple script with an InputAction field
    Code (CSharp):
    1. using TinyLegends.Abilities;
    2. using UnityEngine;
    3. using UnityEngine.InputSystem;
    4.  
    5. namespace TinyLegends
    6. {
    7.     public class AbilityCaster : MonoBehaviour
    8.     {
    9.         public ActiveAbility activeAbility;
    10.         public InputAction inputAction;
    11.  
    12.         private void Awake()
    13.         {
    14.             inputAction.performed += _ => activeAbility.Cast();
    15.         }
    16.     }
    17. }
    But I can't drag the action from the Project window to the field in the Inspector window. It just shows crossed circle cursor.
    upload_2021-6-15_2-41-31.png

    Why is that and how can I reference the InputAction?
     
    Novack and hhoffren like this.
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,947
    Use
    InputActionReference
    for your field instead. I do this all the time, it's great!
     
  3. Tymianek

    Tymianek

    Joined:
    May 16, 2015
    Posts:
    97
    Thanks! :)