- Home /
The question is answered, right answer was accepted
How to check the result after playing in quiz game?[Solve]
Hi all , I want to let the player can check the result is true or false in the end.
Example: questions:1~10 (random) . In the end , the panel will display questions:1~10 (according to front).
But I use random questions, so I have a little stuck.
Should I fix something ? Can someone give me a point.
Now, I can let the question show on display,but it's not correct.
private void ShowQuestion()
{
timeLeft = timeMax;
RemoveAnswerButton();
isRoundActive = true ;
timeRemaining = currentRoundData.timeLimitInSeconds;
questionIndex = Random.Range(0, questionPools.Count);
QueData queData = questionPools[questionIndex];
questionPools.Remove(queData);
queDatatext.text = queData.queText;
explanText.text = queData.explanation.chineseText;
GameObject wordButtonObject = wordObjectPool.GetObject();
wordButtonObject.transform.SetParent(wordParent); **//End panel will display**
WordButton wordButton = wordButtonObject.GetComponent<WordButton>();
wordButton.Setup(GameCon.FindObjectOfType<GameCon>()); //Now the panel will display same
for (int i = 0; i < queData.answers.Length ; i++)
{
RandomButton();
GameObject ansButtonObject = answerButtonObjectPool.GetObject();
answerButtonGameObjects.Add(ansButtonObject);
ansButtonObject.transform.SetParent(ansButtonParent);
AnsButton answerButton = ansButtonObject.GetComponent<AnsButton>();
answerButton.Setup(queData.answers[i]);
StartCoroutine(DownloadTheAudio());
}
StartCoroutine(QAin());
}
WordButton
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WordButton : MonoBehaviour
{
public Text queText;
public Text explainText;
public Color[] changeColor;
private GameCon gamecon;
void Start()
{
}
public void Setup(GameCon data)
{
gamecon= data;
queText.text = gamecon.queDatatext.text;
}
}
Like this
i am having some issues understanding parts of the code, are you already able to display the box with the answers that you have shared or thats what you want to achieve?
it's can display to the box with answer , but it's not correct . ex: if this round questions [4-1-3-9-8-2-10-7-5-6] ,so the true display is [ [4-1-3-9-8-2-10-7-5-6], but the box display [1-5-6-6-10-4-2-1-9-3]. how do I fix it?
Hi @xxmariofer , I already fixed. I fixed the part of Setup . it's can work now. Thank you for take the time to reply me!
hey! its late here i was just going to take a look into it now :) close the question in case people dont see your comment