Completeing number wizard

I wanted to take this a bit further with prompting to play again or ending the game. I have run into two issues. first, is there a command to exit the console through the script? exit, quit, kill, & end have led to dead ends on the search engines. Second, I wrote a reset function that once the game has been won, rather than running Startgame (); to loop the game, I would push to Reset (); that asks if you want to play again and set up key inputs for y/n. It goes to the reset function, but the script doesn’t wait for the y/n input and instead returns to the update function. I was able to work around that within the update function, but that makes the keys active all the time. still seems sloppy to me. suggestions? Below is what I would like, the comments code works if you remove Reset.

void Update () {
if (Input.GetKeyDown(“up”)){
min = guess;
}else if (Input.GetKeyDown(“down”)){
max = guess;
}else if (Input.GetKeyDown(“return”)){
print(“I Won!”);
//print(“Would you like to play again? (y/n)?”);
//}else if (Input.GetKeyDown(“y”)){
// PlayAgain();
//}else if (Input.GetKeyDown(“n”)){
// EndGame ();

void Reset (){
	print("Would you like to play again? (y/n)?");
	if (Input.GetKeyDown("y")){
	}else if (Input.GetKeyDown("n")){
		EndGame ();

I don’t know if this will work in Unity, but in regular c# programming, you
can dispose the main object to close an application. I’d try that. I’m on
my phone, otherwise I would try it myself.

Privacy & Terms