初投稿。気が向いた時にネタあげていきます。
主にコピペ用の簡単ハックを書く予定です。
NGUIのUILabelを一文字ずつ出力するサンプル
TextTest.cs
using UnityEngine;
using System;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
public class TextTest : MonoBehaviour {
void Start () {
string text = "ほげ[FF0000]ほげ[-]ほげ";
//string text = GetComponent<UILabel>().text;
StartCoroutine(textWriter(text));
}
IEnumerator textWriter(string text){
int len = 0;
StringBuilder sb = new StringBuilder();
UILabel label = GetComponent<UILabel>();
label.text = sb.ToString();
Regex r = new Regex(@"^\[[0-9A-F]{6}\]$");
yield return null;
while(len < text.Length){
// Font Colorの評価
string txt = text.Substring( len , 1 );
if (txt == "["){
if (len+3 < text.Length){
txt = text.Substring( len , 3 );
if (txt == "[-]"){
sb.Append( txt );
len += 3;
} else if (len+8 < text.Length){
txt = text.Substring( len , 8 );
if (r.IsMatch(txt)){
sb.Append( txt );
len += 8;
}
}
}
if (len >= text.Length) break;
}
sb.Append( text.Substring( len , 1 ) );
label.text = sb.ToString();
len++;
//Debug.Log(len);
yield return null;
}
yield return null;
}
}