【Unity】打字机效果

来源:互联网 发布:淘宝的权重是什么意思 编辑:程序博客网 时间:2024/05/16 00:38


插入了NGUI   生写打字机效果

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 initializationvoid Start (){font = GameObject.Find ("Font").GetComponent<UILabel> ();}// Update is called once per framevoid 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;}}}


0 0
原创粉丝点击