前提・実現したいこと
現在unityでクイズアプリを作成中です。
問題文と4つの選択肢を解いた後、次の問題文と4つの選択肢を表示、これを何問か繰り返したいのですがどうすればいいのでしょうか。
該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.UI; 5 6public class QuizMgr : MonoBehaviour { 7 8 // Use this for initialization 9 void Start () { 10 QuestionLabelSet (); 11 AnswerLabelSet (); 12 } 13 14 private void QuestionLabelSet(){ 15 //特定の名前オブジェクトを検索してアクセス 16 Text qLabel = GameObject.Find ("Quiz/QLabel").GetComponentInChildren<Text> (); 17 //問題文をセット 18 qLabel.text = "1+1="; 19 } 20 21 private void AnswerLabelSet(){ 22 //回答文面の作成 23 string[] array = new string[]{ "2", "1", "3", "0" }; 24 for (int i = 1; i <= 4; i++) { 25 Text ansLabel = GameObject.Find ("Quiz/AnsButton" + i).GetComponentInChildren<Text> (); 26 ansLabel.text = array [i - 1]; 27 } 28 } 29}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/11 11:08
2018/09/11 11:26
2018/09/11 11:37