//first thing want to do is load the first question //but before load question need to clear any existing answer button private void DisplayQuestions() { RemoveAnsButton(); questionChosen(); QuestionQuizL1E1 qData = qPool[qIndex]; questionT.text = qData.questionT; //going to reach into our question, from question get string, and display that using text //loop over all of the answers and display those and added buttons as needed for (int i = 0; i < qData.answer.Length; i++) { GameObject ansButGameObject = ansButPool.GetObject(); ansButGameObjects.Add(ansButGameObject); // ansButGameObjects.RemoveAt(qIndex); ansButGameObject.transform.SetParent(ansButParent); AButton ansButton = ansButGameObject.GetComponent <AButton>(); ansButton.SetAnsButton(qData.answer[i]); } }
public void ClickAnswerButton(bool isTrue) //call by answer button themselves { if (isTrue) { userScore += currRData.marksForTrueAnswer; showScoreText.text = "Score: " + userScore.ToString(); showSameScoreText.text = "Score: " + userScore.ToString() + "/20"; if (userScore > PlayerPrefs.GetInt("highScore", 0)) { PlayerPrefs.SetInt("highScore", userScore); showHighScore.text = userScore.ToString(); } } else { QuestionQuizL1E1 questionData = qPool[qIndex]; for (int i = 0; i < questionData.answer.Length; i++) { AnswerQuizL1E1 ansData = questionData.answer[i]; if (ansData.isTrue) { Debug.Log(ansData.answerT); // ColorBlock colours = GetComponent<AButton>() // colours.normalColor = Color.red; //GetComponent<Button>().colors = colours; } } } if (qNumber < qPool.Length - 1) { qNumber++; DisplayQuestions(); } else { EndRound(); } }