This is a test script I am trying to use as a base for a much larger and more complicated system (a rhythm-based mode for my game).
I have created 4 public InputActionReferences and have assigned them in editor – all looks well there. I have enabled them, and am simply trying to have it output to the console when one of the actions is performed. That’s it.
As of yet, I have gotten absolutely no feedback from these InputActionReferences. I have boiled the gist of my code up to this point down to the following, and I am wondering – what am I doing wrong? Have I missed some step? I have tried a variety of things, but either nothing has changed from this level, or fatal errors have resulted. The reality is: I really just want a reference to the button presses in the particular action map I care about, not just the button press in general. This feels like a very simple way to complete that objective, but, I really am at a loss for why it doesn’t throw anything. Perhaps something different would complete that goal better? That’d also be valuable feedback.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class TestForInputAction : MonoBehaviour
{
public InputActionReference NoteButton1;
public InputActionReference NoteButton2;
public InputActionReference NoteButton3;
public InputActionReference NoteButton4;
private void Awake()
{
/*
* It hasn't mattered whether or not I use the "ToInputAction()" or just "action". They both seemingly do the same thing, in this case.
* Which is to say...they both have equally not worked, save for simply enabling them.
*/
NoteButton1.ToInputAction().Enable();
NoteButton2.ToInputAction().Enable();
NoteButton3.action.Enable();
NoteButton4.action.Enable();
NoteButton1.ToInputAction().performed += ctx => OnNoteButton("1");
NoteButton2.ToInputAction().performed += ctx => OnNoteButton("2");
NoteButton3.action.performed += ctx => OnNoteButton("3");
NoteButton4.action.performed += ctx => OnNoteButton("4");
}
private void OnNoteButton(string p)
{
Debug.Log("What was pressed: " + p);
}
}
I really would like this to work, and I have found seldom little to help beyond a year-old forum post with a similar issue, but enabling it somehow worked for them, and not for me.
BTW, For some context…I am able to make these button presses do things in my movement script, for example. But that requires me create an instance of my InputActionAsset (called PlayerController, in my context), and to call directly to the action map and action I want like so:
_playerController.FirstActionMap.LightAttackButton.started += ctx => Attack();
But, for this particular use case, I don’t want to have to create a whole new instance of my InputActionAsset – it wouldn’t make much sense. I just want the reference to the action itself to see if it is being pressed.

