サイトはhttps://engineer.blog.lancers.jp/ios/ugui_quiz_unity/を参考にしました
全くの初心者なので分からないことばかりですがよろしくお願いします
エラー内容
以前書いたNull~のエラーは消えましたが別のエラーが出て困っています
(コード内のText qlabelのところです)
Assets\QuizMgr.cs(20,10): error CS1061: 'Text' does not contain a definition for 'Text' and no accessible extension method 'Text' accepting a first argument of type 'Text' could be found (are you missing a using directive or an assembly reference?)
やったこと
類似のサイトで正誤判定について調べました
エラーについて調べました
コード
using UnityEngine;
using System.Collections;
using UnityEngine.UI;//UI オブジェクトを扱う時は必須
public class QuizMgr : MonoBehaviour {
public GameObject QLabel; public string Text; //アタッチしたオブジェクトが呼ばれた時に実行される。 void Start () { QLabelSet (); AnswerLabelSet (); } private void QLabelSet(){ //特定の名前のオブジェクトを検索してアクセス Text qLabel = GameObject.Find("qLabel").GetComponentInChildren<Text> (); //データをセットすることで、既存情報を上書きできる qLabel.Text = "what is this pokemon?"; } private void AnswerLabelSet(){ //回答文面の作成 string[] array = new string[]{"pikachu","pika","pipi","pippi"}; //ボタンが4つあるのでそれぞれ代入 for (int i=1; i<=4 ; i++){ Text ansLabel = GameObject.Find("AnsButton" + i).GetComponentInChildren<Text> (); ansLabel.text = array[i-1]; } }
}
画像
↑画像で示すとこちらです
ページの遷移をしてもテキストがのりません。。。
回答1件
あなたの回答
tips
プレビュー