does not contain a definition for 'Gameplay'

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
colorbar
Posts: 12
Joined: Sun Apr 30, 2023 10:35 pm

does not contain a definition for 'Gameplay'

Post 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.
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: does not contain a definition for 'Gameplay'

Post 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.
colorbar
Posts: 12
Joined: Sun Apr 30, 2023 10:35 pm

Re: does not contain a definition for 'Gameplay'

Post 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
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: does not contain a definition for 'Gameplay'

Post 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.
colorbar
Posts: 12
Joined: Sun Apr 30, 2023 10:35 pm

Re: does not contain a definition for 'Gameplay'

Post by colorbar »

Thank you so much!
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: does not contain a definition for 'Gameplay'

Post by Tony Li »

Glad to help!
Post Reply