//先拿到prefab的Clone的物体:
GameObject go = Resources.Load<GameObject>(MainContainer.PrefabFolder+ "cueText");
cueText= Instantiate(go,GameObject.Find("Canvas").transform);
//开启协程
StartCoroutine(cueTextFade());
生成文字物体后,先把它的透明度置为0,然后让它在0.5秒钟内渐现。
然后停顿1秒。
最后在0.5秒内渐隐。
渐隐结束后,销毁物体。
IEnumerator cueTextFade()
{
//初始化文字,透明度为0
cueText.SetActive(true);
Text text= cueText.GetComponent<Text>();
text.color = new Color(text.color.r,text.color.g,text.color.b,0);
//文字渐现
text.DOFade(1f, 0.5f);
//文字停顿1秒
yield return new WaitForSeconds(1f);
//文字渐隐
text.DOFade(0f, 0.5f);
//渐隐结束后销毁物体
yield return new WaitForSeconds(0.5f);
cueText.SetActive(false);
}