如何使腳本以統(tǒng)一的簡單方式等待/睡眠如何在TextUI.text = ....睡眠功能之間放置,每個短語之間等待3秒?public Text GuessUI;public Text TextUI;[...truncated...]TextUI.text = "Welcome to Number Wizard!";TextUI.text = ("The highest number you can pick is " + max);TextUI.text = ("The lowest number you can pick is " + min);我已經(jīng)嘗試了各種各樣的東西,但沒有奏效,這樣:TextUI.text = "Welcome to Number Wizard!";yield WaitForSeconds (3);TextUI.text = ("The highest number you can pick is " + max);yield WaitForSeconds (3);TextUI.text = ("The lowest number you can pick is " + min);在bash中將是:echo "Welcome to Number Wizard!"sleep 3echo "The highest number you can pick is 1000"sleep 3.....但我無法弄清楚我是如何在Unity中用C#做的
3 回答

回首憶惘然
TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超11個贊
你使用WaitForSeconds是正確的。但我懷疑你嘗試使用它沒有協(xié)同程序。它應(yīng)該如何工作:
public void SomeMethod(){ StartCoroutine(SomeCoroutine());}private IEnumerator SomeCoroutine(){ TextUI.text = "Welcome to Number Wizard!"; yield return new WaitForSeconds (3); TextUI.text = ("The highest number you can pick is " + max); yield return new WaitForSeconds (3); TextUI.text = ("The lowest number you can pick is " + min);}
- 3 回答
- 0 關(guān)注
- 419 瀏覽
添加回答
舉報(bào)
0/150
提交
取消