Page 1 of 1

does not contain a definition for 'Gameplay'

Posted: Tue May 02, 2023 7:54 pm
by colorbar
Hi Tony,

I am sure you've been over this error before, but I tried searching for it, and couldn't find anything.

I am trying to add the RegisterMyControls.cs script you advised in the youtube video about input control, and I keep getting two errors:

"Assets/Scripts/RegisterMyControls.cs(23,153): error CS1061: 'PlayerInput' does not contain a definition for 'Gameplay' and no accessible extension method 'Gameplay' accepting a first argument of type 'PlayerInput' could be found (are you missing a using directive or an assembly reference?)"

"Assets/Scripts/RegisterMyControls.cs(23,77): error CS1061: 'PlayerInput' does not contain a definition for 'Gameplay' and no accessible extension method 'Gameplay' accepting a first argument of type 'PlayerInput' could be found (are you missing a using directive or an assembly reference?)"

I am pretty new to coding, but I got the understood the basic issue - My PlayerInput script does not mention or define a class to 'Gameplay'.

Problem is, I don't know how I would go about doing that. Any guidiance you could give would be very much appreciated. I can post code if needed, but it's the .cs that Unity created and I haven't touched it.

Re: does not contain a definition for 'Gameplay'

Posted: Tue May 02, 2023 8:17 pm
by Tony Li
Hi,

Would you please post the C# script that the Input System has generated? I'll reply back with the RegisterMyControls script that you'll need to use.

Re: does not contain a definition for 'Gameplay'

Posted: Tue May 02, 2023 8:21 pm
by colorbar
It won't let me post the code in the message since it's too long, so I've uploading the file to my dropbox: https://www.dropbox.com/s/m2kwv4qsfx2dr ... ut.cs?dl=0

Re: does not contain a definition for 'Gameplay'

Posted: Tue May 02, 2023 9:01 pm
by Tony Li
Thanks. Try adding this script to your Dialogue Manager:

RegisterMyControls.cs

Code: Select all

using UnityEngine;
using PixelCrushers;

public class RegisterMyControls : MonoBehaviour
{
    protected static bool isRegistered = false;
    private bool didIRegister = false;
    private PlayerInput controls;
    void Awake()
    {
        controls = new PlayerInput();
    }
    void OnEnable()
    {
        if (!isRegistered)
        {
            isRegistered = true;
            didIRegister = true;
            controls.Enable();
            InputDeviceManager.RegisterInputAction("Submit", controls.UI.Submit);
            InputDeviceManager.RegisterInputAction("Cancel", controls.UI.Cancel);
        }
    }
    void OnDisable()
    {
        if (didIRegister)
        {
            isRegistered = false;
            didIRegister = false;
            controls.Disable();
            InputDeviceManager.UnregisterInputAction("Submit");
            InputDeviceManager.UnregisterInputAction("Cancel");
        }
    }
}
This will give the Dialogue System's Input Device Manager access to the inputs named "Submit" and "Cancel". If you need to give it access to more inputs that you've defined in your Input Actions asset, follow the same format for the InputDeviceManager.RegisterInputAction and InputDeviceManger.UnregisterInputAction lines.

Re: does not contain a definition for 'Gameplay'

Posted: Tue May 02, 2023 9:03 pm
by colorbar
Thank you so much!

Re: does not contain a definition for 'Gameplay'

Posted: Tue May 02, 2023 9:15 pm
by Tony Li
Glad to help!