Newbie GUI additions

Hi all,

I’m certain this can be done but on searching nothing comes up.

In c# I wish to have in the editor a choice for some options e.g.

#define joystick 0
#define keyboard 1

I’d like there to be a drop down menu that lets me select “joystick” or “keyboard” rather than 0 or 1.

Can’t see how to do this and define the relevant text that’s added to the menu item and links back to the variable.

Very basic stuff I know; can find it for bools (i.e. a tick box) but not drop down text :frowning:

Any help appreciated

Cheers

Use an enum:

using UnityEngine;

public class MyClass : MonoBehaviour
{
    public enum ControlMethod
    {
	joystick,
	keyboard
    }

    public ControlMethod myControlMethod;
}

Now “myControlMethod” will hold either 0 or 1 depending on what was selected in the drop-down in the inspector, though you will have to cast it to int to use it as an integer.

That’s perfect! - thank-you!

Cheers