Custom New Input System control map

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
gblekkenhorst
Posts: 83
Joined: Wed Jun 24, 2020 5:06 pm

Custom New Input System control map

Post by gblekkenhorst »

I am having trouble with the new input system. My game already has an inputactions file I would like to also use for dialogue system, but I must be missing a step because my script is throwing errors.

My file has an action map called UI with UI inputs. (It's messy right now.)
Screenshot 2023-06-30 124437.png
Screenshot 2023-06-30 124437.png (23.96 KiB) Viewed 1516 times
My event system is pointing at this file. Dialogue Manager has InputDeviceManager attached. I have a script attached called RollerDSInputRegistration.cs, and this is the content:

Code: Select all

using UnityEngine;

namespace PixelCrushers.DialogueSystem
{

    /// <summary>
    /// This class helps the Dialogue System's demo work with the New Input System. It
    /// registers the inputs defined in DemoInputControls for use with the Dialogue 
    /// System's Input Device Manager.
    /// </summary>
    public class RollerDSInputRegistration : MonoBehaviour
    {

#if USE_NEW_INPUT

        private RollerDSInputRegistration controls;

        // Track which instance of this script registered the inputs, to prevent
        // another instance from accidentally unregistering them.
        protected static bool isRegistered = false;
        private bool didIRegister = false;

        void Awake()
        {
            controls = new RollerDSInputRegistration();
        }

        void OnEnable()
        {
            if (!isRegistered)
            {
                isRegistered = true;
                didIRegister = true;
                controls.Enable();
                InputDeviceManager.RegisterInputAction("Horizontal", controls.UI.Horizontal);
                InputDeviceManager.RegisterInputAction("Vertical", controls.UI.Vertical);
                InputDeviceManager.RegisterInputAction("Fire1", controls.UI.Fire1);
            }
        }

        void OnDisable()
        {
            if (didIRegister)
            {
                isRegistered = false;
                didIRegister = false;
                controls.Disable();
                InputDeviceManager.UnregisterInputAction("Horizontal");
                InputDeviceManager.UnregisterInputAction("Vertical");
                InputDeviceManager.UnregisterInputAction("Fire1");
            }
        }

#endif

    }
}
Screenshot 2023-06-30 124437.png
Screenshot 2023-06-30 124437.png (23.96 KiB) Viewed 1516 times
Am I missing something? Thanks!
Attachments
Screenshot 2023-06-30 130739.png
Screenshot 2023-06-30 130739.png (28 KiB) Viewed 1516 times
User avatar
Tony Li
Posts: 22125
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom New Input System control map

Post by Tony Li »

Hi,

Inspect your scene's EventSystem GameObject. You may need to click a button to update it to use the Input System.

Select your Input Actions asset. In the Inspector, tick Generate C# Class:

Image

This will create a C# script named something like RollerGirlsInput.cs. In your registration script, change this line:

Code: Select all

private RollerDSInputRegistration controls;
to use that script name, like:

Code: Select all

private RollerGirlsInput controls;
gblekkenhorst
Posts: 83
Joined: Wed Jun 24, 2020 5:06 pm

Re: Custom New Input System control map

Post by gblekkenhorst »

I've tried that, but I'm getting the error

Code: Select all

Assets\Plugins\Pixel Crushers\Dialogue System\Demo\Scenes\New Input System\RollerDSInputRegistration.cs(16,25): error CS0246: The type or namespace name 'RollerGirlInputs' could not be found (are you missing a using directive or an assembly reference?)
Does the generated CS class need to be in a specific place to be found by the script?
User avatar
Tony Li
Posts: 22125
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom New Input System control map

Post by Tony Li »

Hi,

Yes, it needs to be outside of the Plugins folder -- such as in your own scripts folder.
gblekkenhorst
Posts: 83
Joined: Wed Jun 24, 2020 5:06 pm

Re: Custom New Input System control map

Post by gblekkenhorst »

That was an issue, that error is cleared now!

I tested with a conversation trigging on start, and that works great!

My action Interact does not seem to be triggering the Proximity selector. Is there another step to get this working?

Also occasionally (doesn't even seem to be tied to input, it just triggers a minute or two after entering play mode.

Code: Select all

Action has been triggered but apparently not from an interaction yet there's interactions on the binding that got triggered?!?
UnityEngine.InputSystem.InputActionAsset:Disable ()
RollerGirlInputs:Disable () (at Assets/_George/RollerMovement/RollerGirlInputs.cs:1324)
PixelCrushers.DialogueSystem.RollerDSInputRegistration:OnDisable () (at Assets/_George/RollerMovement/RollerDSInputRegistration.cs:47)
User avatar
Tony Li
Posts: 22125
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom New Input System control map

Post by Tony Li »

Hi,

What is the name of the Interact action? "Interact"? If so, did you register "Interact" in your RollerDSInputRegistration script and also set the Proximity Selector's Use Button to "Interact"?
Post Reply