对话用的
功能是一个一个字的显示
功能是一个一个字的显示
using UnityEngine;
using System.Collections;
public class TestRootCode : MonoBehaviour {
public Vector3 myVec = new Vector3(1,1,1);
public string myText;
public int i = 0;
public float delataTime;
// Use this for initialization
void Start () {
myText = "adjkfhlasdkjfhasdljkfhksdaljhfalskjdfhsdkj";
i = 0;
delataTime = 0;
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
delataTime -= Time.deltaTime;
string myStr = myText.Substring (0, i);
GUILayout.Label (myStr);
if (delataTime < 0) {
delataTime = 1f;
if(i>=myText.Length)
{
return;
}else{
i++;
}
}
}
}