Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

[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:
    90
    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,554
    Use
    InputActionReference
    for your field instead. I do this all the time, it's great!
     
    Novack, ow3n, Boolable and 3 others like this.
  3. Tymianek

    Tymianek

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