Question by
bnd10706_unity · Aug 14, 2019 at 08:09 PM ·
wait
Waiting for UI Button option
I am having a UI pop up with a Yes/ No option. The problem is while the script calls the yes/no option and everything "works" it is doing it in the background and never really giving the player the option to say yes or no. How do I pause the script until a condition is met?
This is what I have so far
public bool AskForTakingMoney(){
takingMoneyBox.SetActive(true);
goldText.text = "Current Gold: " + GameManager.instance.currentGold.ToString() + "G";
questionText.text = "Pay the " + DialogManager.instance.goldAmount + "G?";
Debug.Log("At the Taking Money Script the value is:::: " + saysYes);
StartCoroutine(Wait());
return saysYes;
}
public void SaysYes(){
saysYes = true;
selectedAnswer = true;
takingMoneyBox.SetActive(false);
}
public void SaysNo(){
saysYes = false;
selectedAnswer = true;
takingMoneyBox.SetActive(false);
}
IEnumerator Wait(){
yield return new WaitUntil(() => selectedAnswer == true);
}
Comment
Your answer
Follow this Question
Related Questions
Wait inside a non void method 1 Answer
Wait Until Press a Button 1 Answer
Wait 2 seconds in Update 1 Answer
Noobie question: wait a random time 1 Answer
How to delay an action in Untiy 1 Answer