using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Texts : MonoBehaviour {
public Text m_txt;
public Text color;
public string m_string;
public float currTime;
public float m_speed= 0f;
bool Begin;
void Start () {
Begin = false;
m_string = m_txt.text;
Being();
}
void Update () {
Tween();
begin();
}
void Being()
{
m_txt.text = "";
currTime = 0f;
}
void Tween() // 打字
{
if (Begin)
{
m_txt.text = m_string.Substring(0, (int)(currTime * m_speed));
currTime += Time.deltaTime;
}
}
void begin() // 判断是否打字
{
if (m_txt.text.Length< m_string.Length )
{
Begin = true;
}
if(m_txt.text.Length == m_string.Length)
{
Begin = false;
color.enabled = true;
}
}
}