private void SetCurrentQuestion() { if (questionCount == questionPool.Length || healthCount == 0) { EndRound(); } else { RemoveAnswerButtons(); int randomQuestionIndex = random.Next(0, unansweredQuestions.Count); currentQuestion = unansweredQuestions[randomQuestionIndex]; questionTextDisplay.text = currentQuestion.question; for (int i = 0; i < currentQuestion.choices.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObject.transform.SetParent(answerButtonParent); answerButtonGameObjects.Add(answerButtonGameObject); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(currentQuestion.choices[i]); } unansweredQuestions.Remove(currentQuestion); } }
private void SetCurrentQuestion() { choiceA.enabled = true; choiceB.enabled = true; choiceC.enabled = true; choiceD.enabled = true; if (questionCount == questionPool.Length || healthCount == 0) { EndRound(); } else { int randomQuestionIndex = random.Next(0, unansweredQuestions.Count); currentQuestion = unansweredQuestions[randomQuestionIndex]; questionTextDisplay.text = currentQuestion.question; /* * RemoveAnswerButtons(); * for (int i = 0; i < currentQuestion.choices.Length; i++) * { * GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); * answerButtonGameObject.transform.SetParent(answerButtonParent); * answerButtonGameObjects.Add(answerButtonGameObject); * AnswerButton answerButton = answerButtonGameObject.GetComponent<AnswerButton>(); * answerButton.Setup(currentQuestion.choices[i]); * } */ unansweredQuestions.Remove(currentQuestion); choice1.text = currentQuestion.choices[0].choice.ToString(); choice2.text = currentQuestion.choices[1].choice.ToString(); choice3.text = currentQuestion.choices[2].choice.ToString(); choice4.text = currentQuestion.choices[3].choice.ToString(); } }