Compile Errors from New Input System Registration

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
museaeli
Posts: 3
Joined: Wed Feb 12, 2025 8:47 pm

Compile Errors from New Input System Registration

Post by museaeli »

I am working on implementing the dialogue system to a NIS based third person game.

I have been following the official tutorial video to get the QuickStart conversation to begin when approaching a character and pressing "E."

I have generated the C# class script from the Input Action asset, called "PlayerControls"

My registration script, "DSRegNewInput" contains the following code:

Code: Select all

using UnityEngine;
using UnityEngine.InputSystem;
using PixelCrushers;

//Makes Unity's New Input System actions available to Dialogue System. PlayerInput component is not required
//Copy syntax to add new actions, names must be EXACT matches (incl. capitalization)
//Name in quotes is what will be used by Dialogue System
//Also add to OnDisable to allow them to be turned on and off at will

//xxx.playerMovement.Back | Input Action C# class script name
//playerControls.xxx.Back | Action map name
//playerControls.playerMovement.XXX | Action name


public class DSNewInput : MonoBehaviour
{
    protected static bool isRegistered = false;
    private bool didIRegister = false;
    private PlayerControls controls;
    void Awake()
    {
        controls = new MyControls();
    }
    void OnEnable()
    {
        if (!isRegistered)
        {
            isRegistered = true;
            didIRegister = true;
            controls.Enable();
            InputDeviceManager.RegisterInputAction("Back", PlayerControls.playerMovement.Back);
            InputDeviceManager.RegisterInputAction("Interact", PlayerControls.playerMovement.Interact);
            InputDeviceManager.RegisterInputAction("Submit", PlayerControls.UI.Submit);
            InputDeviceManager.RegisterInputAction("Cancel", PlayerControls.UI.Cancel);
            InputDeviceManager.RegisterInputAction("Navigate", PlayerControls.UI.Navigate);
            InputDeviceManager.RegisterInputAction("OpenInventory", PlayerControls.UI.OpenInventory);
        }
    }
    void OnDisable()
    {
        if (didIRegister)
        {
            isRegistered = false;
            didIRegister = false;
            controls.Disable();
            InputDeviceManager.UnregisterInputAction("Back");
            InputDeviceManager.UnregisterInputAction("Interact");
            InputDeviceManager.UnregisterInputAction("Submit");
            InputDeviceManager.UnregisterInputAction("Cancel");
            InputDeviceManager.UnregisterInputAction("Navigate");
            InputDeviceManager.UnregisterInputAction("OpenInventory");
        }
    }

}
"DSRegNewInput" and "PlayerControls" are both next to each other in Assets\Scripts

When trying to launch the game I get 7 compile errors:

Code: Select all

Assets\Scripts\DSRegNewInput.cs(32,64): error CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.playerMovement' 
(and a variation of this for each input I am trying to register)
plus

Code: Select all

Assets\Scripts\DSRegNewInput.cs(22,24): error CS0246: The type or namespace name 'MyControls' could not be found (are you missing a using directive or an assembly reference?)
I am at a bit of a loss as to where to go from here. I have restarted the process once before as well as re-imported the "Scripts" and "Wrappers" folder of Dialogue System.

Thanks in advance for any advice :)
museaeli
Posts: 3
Joined: Wed Feb 12, 2025 8:47 pm

Re: Compile Errors from New Input System Registration

Post by museaeli »

In case it's helpful, I am using Unity 2021.3.43f1 LTS on Windows.
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Compile Errors from New Input System Registration

Post by Tony Li »

Hi,

To update that script, you'd need to change 'MyControls' to the name of the script created for your actions asset.

However, the upcoming version 2.2.51 has a much simpler way to register input actions. It adds an Input Action Registry component. Here's a patch to add that component to your project:

PixelCrushers_InputActionRegistry_2025-02-11.unitypackage

Try these steps:

1. Delete your DSNewInput script.

2. Import the patch above.

3. Add the new Input Action Registry component to your Dialogue Manager.

4. Expand your input actions asset. Add the input actions (Back, Interact, Submit, etc.) to the Input Action Registry component's list.

This will automatically register the input actions with the Dialogue System. You don't need to write any scripts.
museaeli
Posts: 3
Joined: Wed Feb 12, 2025 8:47 pm

Re: Compile Errors from New Input System Registration

Post by museaeli »

Thanks very much Tony! I was not expecting a whole patch to be ready to go :) I'll get this added later today. Have a great week :mrgreen:
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Compile Errors from New Input System Registration

Post by Tony Li »

Glad to help! If you have any questions about using the new Input Action Registry component, just let me know.
Post Reply