Created
January 4, 2015 14:45
-
-
Save tsubaki/4a53b925ca02f5a0cffc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Linq; | |
using SysRandom = System.Random; | |
using UnityEngine.UI; | |
public class sendtext : MonoBehaviour | |
{ | |
private string[] m_textStr = { | |
"装備は装備しないと意味無いよ", | |
"はじまりの村へようこそ!", | |
"おぃい早く世界を平和にすべきそうすべき" }; | |
private int m_textPos = 0; | |
private int m_curTim = 0; | |
public Text text; | |
SysRandom rnd; | |
string currentText = string.Empty; | |
void Start () | |
{ | |
text.text = string.Empty; | |
ResetText (); | |
} | |
void ResetText () | |
{ | |
rnd = new SysRandom (); | |
m_textPos = 0; | |
m_curTim = 0; | |
currentText = m_textStr [rnd.Next (m_textStr.Length)]; | |
} | |
void Update () | |
{ | |
int nowTim = (int)(Time.realtimeSinceStartup * 1000.0f); | |
if (nowTim - m_curTim >= 120) { | |
m_curTim = nowTim; | |
if (m_textPos <= currentText.Length) { | |
string str = currentText.Substring (0, m_textPos); | |
text.text = str; | |
m_textPos++; | |
} else { | |
ResetText (); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment