Last active
August 29, 2015 14:10
-
-
Save tsubaki/660eede7383743171dcd 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 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