Here’s my problem. I am making a quiz application via Unity and I stumbled on a beginner’s problem I suppose. So basically, I prepared 8 questions. These 8 questions are listed in an array. I made another array that holds the answers to those questions. Like this:
public static string [] bquizbeeQuestions = {
"Q1",
"Q2",
"Q3",
"Q4",
"Q5",
"Q6",
"Q7",
"Q8",
};
public static string [] bquizbeeAnswers = {
"1", "2", "3", "4", "5", "6", "7", "8"
};
Currently, I use a Input key for the answers because it’s easier to check the player’s answer. But I want to do a multiple choice instead. I tried it before and failed, of what I want to consult today. So anyway, my problem is this:
How can I randomize the multiple choice button texts and not each of them repeat the same word from the list I made?
This is what I mean.
First, I made an array that has a list of words that may appear as the text in the button:
public static string [] titles = {
"Workload", "Thread", "Mining", "Serendipity", "Charge", "Weight", "Altruistic"
};
What I do to make these appear in the button as their text is this:
void setButtonText() {
switch(BQuizBeeReviewer.slug) {
case "title":
for (int x = 0; x < button.Length; x++) {
if(x == realButtonAnswer) {
button[x].text = BQuizBeeReviewer.bquizbeeAnswers[die];
buttonHit[x].onClick.AddListener(() => { setButtonClickAnswer(BQuizBeeReviewer.bquizbeeAnswers[die]); });
} else {
buttonHit[x].onClick.AddListener(() => { setButtonClickAnswer(BQuizBeeReviewer.titles[Random.Range(0, BQuizBeeReviewer.titles.Length)]); });
button[x].text = BQuizBeeReviewer.titles[Random.Range(0, BQuizBeeReviewer.titles.Length)];
}
}
break;
default:
break;
}
}
I am having problems with this because I saw that automatically, the buttons are activated. I was wondering if you guys have a better solution of making a randomized multiple choice buttons where there is only one right answer button while the others are wrong.
Maybe someone can pinpoint me to a tutorial as well that tackles this.