- Home /
How do I make a button press transition between phases properly?
Hi there.
So at the end of my game I want a GUI, controlled by a separate script to show up for the player to view/read. However, when press the button that triggers the end, which is the same button to continue through the GUI, I end up with one of two issues as I mess with the code.
1) The code senses that the same button used to end the game and activate the GUI are the same and speeds right through the GUI, only showing it for a split second, to reload the game, as per my script, leaving no chance for the player to stop and read the GUI splash page.
OR
2) The GUI shows up and the game stops in the right place. However, it refuses to respond to future commands. Pressing the button will not do anything nor reload the game as I wanted.
I've tried many different methods from booleans to if statements and nothing seems to work. Here's the code for the part of my the part of my code controlling the issue. This version of it has the second problem I mentioned. It seems that the yield is the cause of it being nonresponsive, though I don't know why.
else {
Debug.Log (" END OF GAME! ");
engine2.GetComponent<FreudUtil>().EndQuiz();
results = true;
engine.GetComponent<EndResult1>().showResults = true;
yield return new WaitForSeconds(1.0f);
if (Input.GetKeyDown(KeyCode.Space)) {
Application.LoadLevel("TitleScreen");
}
}
Your answer
Follow this Question
Related Questions
GUI.Button's status react to keyboard event? 0 Answers
Show GUI.Button press state by keyboard input? 1 Answer
Move GUI elements. 0 Answers
Using GUI and check what button was pressed 1 Answer
GUI Button Disappearing 1 Answer