Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created January 4, 2015 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/4a53b925ca02f5a0cffc to your computer and use it in GitHub Desktop.
Save tsubaki/4a53b925ca02f5a0cffc to your computer and use it in GitHub Desktop.
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