Hope I can find some help here (once again) after thinking a lot myself about the problem without finding a solution…
So here’s what I want to do: I have a turn-based battle system that is based on a “big” while-loop. In this while-loop I call a method “Move();”, this method will show the GUI if the mob is a player or get a move automatically if the mob is a npc. The problem I get here is that I don’t know how I could freeze/stop the code here until the user has pressed a GUI.button (and thus select a move). The code in the while-loop will just continue to the next part of the code and everything will become a mess (since the players move = null).
What I’ve tried: Creating a new “IEnumerator Wait()” that will “yield return new WaitForSeconds(0.1f);” while the GUI is shown (the GUI will dissappear after a GUI.Button is clicked on) (I would call Wait() from Move()). This however does not work since the while-loop here does not in fact stop the “big” while-loop which it is called from from continuing.
If it was possible I would just call a method that shows the GUI.Buttons and then requires a “return”, but this is not possible since the only(?) way to show GUI.Buttons is through “void OnGUI()”.
EDIT: The “big” while-loop can not be a Enumerator since the class is not derived from MonoBehaviour (and can thus not use StartCorountine). I tried to rewrite it so it was based of MonoBehaviour but ran in to all sorts of errors when trying to call it.
EDIT #2: I have found a way to successfully make the “big” while-loop a coroutine and execute it But the question remains how I could wait for a user-input through GUI.Button.