【Unity】打字机效果


插入了NGUI   生写打字机效果this

using UnityEngine;
using System.Collections;

public class ShowFont : MonoBehaviour
{
	private  float ShowTime = 0.2f;
	private int count = 0;
	private UILabel font;
	private string str = "     二十年前,东方未名辞让掌门以后,便离开逍遥谷,云游四海,纵身于山水之间,寄情于花鸟之闲。然而他的足迹遍及各地,而所到之处总会留下许多他的传闻。 东方未明于二十年后重返逍遥谷.";
	// Use this for initialization
	void Start ()
	{
		font = GameObject.Find ("Font").GetComponent<UILabel> ();
	}

	// Update is called once per frame
	void Update ()
	{
		if (count == str.Length - 1) {
			Application.LoadLevel (2);
		}
		ShowTime -= Time.deltaTime;
		if (ShowTime <= 0 && count <= str.Length - 1) {
			font.text += str [count++];
			ShowTime = 0.2f;
		}
	}
}