I would like to create a function which returns a value based on some user choices (clicks on GUI buttons).
Is it possible to do this?
The function should be something like
int getUserChoice(){
/*
* When the user finishes clicking on the GUI buttons, another thread
* sets the user choice to its actual value. Until then its value is -1.
*/
userChoice = -1;
displayAvailableChoices();
while(userChoice < 0)
yield return WaitForFixedUpdate();
return userChoice;
}
The problem is that I can’t use the yield statement because the function is not a “IEnumerator”.
Is there any way I can do this?
It’s not like I cannot have a callback function, but this would simplify A LOT my classes (because of polymorphism).
Thank you in advance
P.S.
The code is not actually this one, it’s a lot more complicated, but you get the idea