I’m trying to create a Coroutine, which is supposed to check if a bool is true. Although, it seems to just skip that and run the rest of the code.
Here’s the Ienumerator:
IEnumerator waitForInput(bool checkThis)
{
while (checkThis == true)
{
yield return null;
}
yield return null;
}
Here’s the function that calls the StartCoroutine
void mainMenu()
{
textScreen.text = "Welcome to the main menu!
Please select your desired program:
-
WifiHack
-
CameraHack
-
Exit";
StartCoroutine(inputChanged); //check what the input was here. Debug.Log("Didn't work."); }
As you can see, I’m telling it to start the coroutine and check if my bool is true. I’ve created a Debug.log message, so I know if it has been skipped. That log message fires each time I play the game.
The inputChanged bool is set to false on Start() function. Same goes with the mainMenu() function being called:
void Start()
{
inputChanged = false;
mainMenu();
}
Someone was having the same problem as me, although that was with a keypress: “Waiting for Input via Coroutine - Questions & Answers - Unity Discussions”
Any help, greatly appreciated!
EDIT: Just adding my comment up here, to state my intentions a bit clearer:
“What I’m trying to create is a terminal-like computer ui, using Unity’s UI system. I have a function called OnEndEdit, which of course is linked to an InputField calling that on OnEndEdit. Would it be possible to use that function to check for input? Thing is, I could call the main menu in the onEndEdit function, and all of this would work, although I would very much like to create different functions for each program that I create, to make further adding of programs simpler!”