Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.