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

Hey
I want to reference an InputAction in my code.

I have a CastSpell1 action defined in the new Input System


I have a simple script with an InputAction field

using TinyLegends.Abilities;
using UnityEngine;
using UnityEngine.InputSystem;

namespace TinyLegends
{
    public class AbilityCaster : MonoBehaviour
    {
        public ActiveAbility activeAbility;
        public InputAction inputAction;

        private void Awake()
        {
            inputAction.performed += _ => activeAbility.Cast();
        }
    }
}

But I can’t drag the action from the Project window to the field in the Inspector window. It just shows crossed circle cursor.

Why is that and how can I reference the InputAction?

2 Likes

Use InputActionReference for your field instead. I do this all the time, it’s great!

8 Likes

Thanks! :slight_smile: