Unity 入门打字机效果
使用协程加延迟
public class UIDazhi : MonoBehaviour
{
public Text t;
//private string currentstr = "";
public string str = "欢迎来到Unity的世界";
// Start is called before the first frame update
void Start()
{
Debug.Log("12");
t.text = "";
StartCoroutine( Fade());
}
IEnumerator Fade()
{
yield return null;
for (int i = 0; i <= str.Length; i++)
{
Debug.Log("sadf");
t.text = str.Substring(0, i);
yield return new WaitForSeconds(0.5f);//延迟0.5秒
}
}
// Update is called once per frame
void Update()
{
}
}
版权声明:本文为qq_51654332原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。