- void Update()
- {
- switch (“input”)
- {
- case “y”:
- Application.Quit();
- break;
- case “n”:
- quitgametext.SetActive(false);
- break;
- }
-
- }
You can have a variable called key of type string, set the value of key when they press “Y” for example, then use your switch, but I don’t know why you would do that when you could just use a series of if statements, arguably smaller and easier to read than the switch statement.
While it depends on your input system, using the KeyCode enumeration that is provided by Unity might be an idea.
It seems that you confuse string and char literals:
string text = "input"; // text that consists of the characters i, n, p, u, t
char character = 'y'; // a single character
So in your provided case:
void Update()
{
char input = /* some key */;
switch (input)
{
case 'y':
Application.Quit();
break;
case 'n':
quitgametext.SetActive(false);
break;
}
}
Thanks!