我想顯示我的文本 3 秒鐘,所以我做了以下操作,但它只是閃爍并消失。 void Start () { Invoke("ShowInfoText", 2f); }void ShowInfoText(){ infoText.gameObject.SetActive(true); infoText.text = "Welocme!"; Invoke("DisableInfoText", 5f);}void DisableInfoText(){ infoText.gameObject.SetActive(false);}如何讓文字停留3秒?
1 回答

哆啦的時(shí)光機(jī)
TA貢獻(xiàn)1779條經(jīng)驗(yàn) 獲得超6個(gè)贊
你可以試試InvokeRepeating。
public void InvokeRepeating(string methodName, float time, float RepeatRate );
您還可以使用協(xié)程:
void Start ()
{
StartCoroutine(DoTextShow());
}
IEnumerator DoTextShow()
{
infoText.gameObject.SetActive(false);
yield return new WaitForSeconds(2f);
infoText.gameObject.SetActive(true);
yield return new WaitForSeconds(3f);
infoText.gameObject.SetActive(false);
}
- 1 回答
- 0 關(guān)注
- 138 瀏覽
添加回答
舉報(bào)
0/150
提交
取消