using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class QuizManager : MonoBehaviour
{
public List<QuestionsAndAnswers> QnA;
public GameObject[] options;
public int currentQuestion;
private Text QuestionTxt;
private void start()
{
generateQuestion();
}
void SetAnswers()
{
for (int i = 0; i < options.Length; i )
{
options[i].transform.GetChild(0).GetComponent<Text>().text = QnA[currentQuestion].Answers.[i];
}
}
void generateQuestion()
{
currentQuestion = Random.Range(0, QnA.Count);
QuestionTxt.text = QnA[currentQuestion].Question;
}
}
I cant find the problem?? I know the problem is in the 23 line, its expeting something but i cant find what. Ive looked in the web and cant find.
CodePudding user response:
Cold be the dot at the end of the line? But I don't know the datatype of Answers.
// yours
options[i].transform.GetChild(0).GetComponent<Text>().text = QnA[currentQuestion].Answers.[i];
// new
options[i].transform.GetChild(0).GetComponent<Text>().text = QnA[currentQuestion].Answers[i];