[英]Making text in text mesh stay for few seconds
I want to display my text for 3 seconds, so I did the following, but it is just blinking and disappearing.我想显示我的文本 3 秒钟,所以我做了以下操作,但它只是闪烁和消失。
void Start () {
Invoke("ShowInfoText", 2f);
}
void ShowInfoText()
{
infoText.gameObject.SetActive(true);
infoText.text = "Welocme!";
Invoke("DisableInfoText", 5f);
}
void DisableInfoText()
{
infoText.gameObject.SetActive(false);
}
How do I make the text to stay for 3 seconds?如何让文字停留 3 秒?
You could try InvokeRepeating
.你可以试试
InvokeRepeating
。
public void InvokeRepeating(string methodName, float time, float repeatRate );
public void InvokeRepeating(string methodName, float time, float repeatRate );
You could also use a Coroutine:您还可以使用协程:
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.