亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使文本網格中的文本停留幾秒鐘

使文本網格中的文本停留幾秒鐘

C#
海綿寶寶撒 2023-07-22 18:27:50
我想顯示我的文本 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 回答

?
哆啦的時光機

TA貢獻1779條經驗 獲得超6個贊

你可以試試InvokeRepeating。


public void InvokeRepeating(string methodName, float time, float RepeatRate );


您還可以使用協程:


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);

}


查看完整回答
反對 回復 2023-07-22
  • 1 回答
  • 0 關注
  • 139 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號