Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active August 29, 2015 14:10
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/660eede7383743171dcd to your computer and use it in GitHub Desktop.
Save tsubaki/660eede7383743171dcd to your computer and use it in GitHub Desktop.
超簡単なテキスト制御機能
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // uGUIの機能を使うお約束
public class TextController : MonoBehaviour {
public string[] scenarios; // シナリオを格納する
public Text uiText; // uiTextへの参照を保つ
int currentLine = 0; // 現在の行番号
void Start()
{
TextUpdate();
}
void Update ()
{
// 現在の行番号がラストまで行ってない状態でクリックすると、テキストを更新する
if(currentLine < scenarios.Length && Input.GetMouseButtonDown(0))
{
TextUpdate();
}
}
// テキストを更新する
void TextUpdate()
{
// 現在の行のテキストをuiTextに流し込み、現在の行番号を一つ追加する
uiText.text = scenarios[currentLine];
currentLine ++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment