How to configure Input for controlling dialogue selection using the New Input System

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
EffieArtoria
Posts: 9
Joined: Mon Mar 08, 2021 6:45 pm

How to configure Input for controlling dialogue selection using the New Input System

Post by EffieArtoria »

Hi,

I'm having trouble getting my head around how to use the New Input System to let the player control dialogue- i.e selecting dialogue options from a list. Initiating dialogue is fine, but I'm just totally lost once I get into the dialogue.

I've followed these steps:
  • Followed the Quick Start Guide in a new project
  • Ticked New Input System in the Dialogue System Welcome page
  • Told Unity to use the New Input System
  • Created an InputActions asset, set it up
    Image
  • Written code to register my new Inputs with the Input Device Manager, and added that as a component to my Input Manager

    Code: Select all

            protected static bool isRegistered = false;
            private bool didIRegister = false;
            private MasterInput controls;
            void Awake()
            {
                controls = new MasterInput();
            }
            void OnEnable()
            {
                if (!isRegistered)
                {
                    isRegistered = true;
                    didIRegister = true;
                    controls.Enable();
                    InputDeviceManager.RegisterInputAction("Submit", controls.Player.Interact);
                    InputDeviceManager.RegisterInputAction("Cancel", controls.Player.Cancel);
                    InputDeviceManager.RegisterInputAction("Movement", controls.Player.Movement);
                }
            }
            
            void OnDisable()
            {
                if (didIRegister)
                {
                    isRegistered = false;
                    didIRegister = false;
                    controls.Disable();
                    InputDeviceManager.UnregisterInputAction("Submit");
                    InputDeviceManager.UnregisterInputAction("Cancel");
                    InputDeviceManager.UnregisterInputAction("Movement");
                }
            }
However, I'm not sure what step to follow next in order to use those inputs. I've searched the manual for mention of input and only found eliptical mentions. If it's in there, I'm missing it. What classes do I have to edit, and where to, for instance, allow the player to use my "Movement" Input to move up and down between dialogue options? Is it somewhere in the templates...? Do I have to fiddle around extensively with the Input Device Manager settings like Key Codes to Check?

Sorry if I'm being dense. I did spend a long time looking and reading on my own before deciding to post.
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to configure Input for controlling dialogue selection using the New Input System

Post by Tony Li »

Hi,

You don't need to register Submit or Cancel to navigate dialogue UI continue buttons or player response menus. That's all done through Unity UI. Make sure your scene has an EventSystem GameObject with an InputSystemUIInputModule module, not a StandaloneInputModule. The StandaloneInputModule is for the built-in Unity input manager system, not the new Input System. However, you may want to register Cancel using the script in your post if the Input Device Manager is reporting an error that it's not registered. (Special menus, such as the Dialogue System's free menu framework addon, use the Input Device Manager's Back input.)
EffieArtoria
Posts: 9
Joined: Mon Mar 08, 2021 6:45 pm

Re: How to configure Input for controlling dialogue selection using the New Input System

Post by EffieArtoria »

Thank you, that was what I was missing. I let out a little shout of joy when it finally worked!
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to configure Input for controlling dialogue selection using the New Input System

Post by Tony Li »

Happy to help! :-)
Post Reply