#the thing is it will have hundreds of

1 messages · Page 1 of 1 (latest)

desert umbra
#

alright, create a class not deriving from monobehaviour called question or something like that

#

in that class, have some variables like

#

string question, string[] answers

#

then in another script deriving from monobehaviour and that has references to the question text object and the answer buttons, store a bunch of questions in an array

#

if your questions class is Question

#

then Question[] questions;

#

if you make it public, then you can set all the questions in the inspector

final wave
#

ty

#

i wanted to make something like this

#

and each button sending you to a scene with the question

#

and by pressing the correct answer, chosing either to go to the menu or to the next question

#

but I guess it will take a lot of space

desert umbra
#

ooh i see

#

alright

#

i'm still thinking something similar to what i mentioned earlier

#

so having an overall array of questions

#

and then getting the correct question from the array based on the the button clicked

final wave
#

I will try as in the video you sent

#

It will be a little harder, as my game has 4 answers and it's not just a good answer and a bad one

desert umbra
#

yep it will be a little harder

#

but the overall idea is the same

#

i actually made something like your idea right now, just without the question select

#

here's a screenshot of how i set it up

#

so on the right hand side

#

you can see how i'm making questions in the inspector

#

granted

#

my version is probably more complicated than you want yours to be

#

because i have multiple select, so multiple correct answers

final wave
#

yeah that shouldnt be a problem

#

my problem is i dont want it to be random, and choose what questions you want to answer

desert umbra
#

yep completely understood, i'm thinking you have two scenes: one for question selection, and then one for the actual gameplay

final wave
desert umbra
#

great

#

now in the one for the questions, set up an array of questions the way i did

#

and in the one for the question select

#

make a parent gameobject for all your buttons

#

now attach a script to that parent gameobject

final wave
#

let me make the scene

desert umbra
#

of course, i'll first type out my ideas

final wave
#

Actually I dont even need a questions yet, most of the question sets are either images or audio

#

now thinking about it it's the same thing

desert umbra
#

yep, the main problem here is we want to connect the buttons somehow to a question in the array

#

so like button[0] = question[0]

#

hmm i'm thinking of something like

#

having a parent object with all the buttons as children

#

then in a script on the parent object

#

have an array of gameobjects for your buttons, you can name it anything you want

#

then at start, have a for loop that loops through transform.childCount

final wave
#

I've done something fast, i will change the design when I make this think work

#

it's for phone btw

final wave
desert umbra
#
List<GameObject> buttons = new List<GameObject>();
for (int i = 0; i < transform.childCount; i++) {
  buttons.Add(transform.GetChilld(i));
}
#

so now you have all the buttons in your scene in an array

#

now whenever a button is pressed

#

hook it up to this parent script

#

and call some function like LoadScene

#
public void LoadQuestion(GameObject button) {
  int questionIndex = buttons.IndexOf(button);
}
#

so now you have the index of the question you want to load

#

however, the issue is that we need to find a way to send that questionIndex to the next scene, which tbh at the moment i'm not sure how to do

#

but i hope you get the general idea

#

you have two arrays, one of your buttons and one of your questions

#

you're essentially trying to hook the two up, even though they're in different scenes

final wave
#

I can use playerprefs

desert umbra
#

oh sure that could work

#

well let me know how it turns out and if you have any issues