Reputation: 669
I'm trying to set up the new input system in my unity project.
I have created my Input actions and attached a player input component to my game object.
Ive then attached a script to the GO.
I'm trying to use the unity events.
Ive dragged my script (i also tested dragging the GO itself) from the GO into on of my input actions but when I try and select my function it doesnt appear in the list.
PlayerInputHandler.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInputHandler : MonoBehaviour
{
void OnMoveInput(InputAction.CallbackContext context)
{
Debug.Log("OnMoveInput");
}
void OnJumpInput(InputAction.CallbackContext context)
{
Debug.Log("OnJumpInput");
}
}
Upvotes: 1
Views: 3355
Reputation: 1
This happened to me as well, when attempting the new input system,
we just forgot to enable something of the new input system
Project Settings > Input system package > enable the checkbox named "Enable Input consumption".
That's it you will see the your callback function name in the players inspector screen
Upvotes: 0
Reputation: 8546
I was having the same problem. It turns out, the handler method must not be private.
Try this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInputHandler : MonoBehaviour
{
public void OnMoveInput(InputAction.CallbackContext context)
{
Debug.Log("OnMoveInput");
}
public void OnJumpInput(InputAction.CallbackContext context)
{
Debug.Log("OnJumpInput");
}
}
Upvotes: 0