using UnityEngine;
using UnityEngine.UI;
public class TypeEffect : MonoBehaviour {
float letterpause = 0.2f;
AudioClip clip;
private string word;
private string text = "sdfdsgfghrturjhgfbsgdasf";
public Text showtext;
// Use this for initialization
IEnumerator Start () {
word = text;
text = null;
yield return new WaitForSeconds(2f);
StartCoroutine (TypeWord());
}
IEnumerator TypeWord()
{
foreach (var item in word.ToCharArray())
{
showtext.text += item;
this.GetComponent<AudioSource>().PlayOneShot(clip, 1f);
yield return new WaitForSeconds(letterpause);
}
}
}
UGUI打字机效果
最新推荐文章于 2023-06-08 10:02:31 发布