is it possible toggle bool at editor by script?
I have a GameDataEditor. I entry my questions by this but I want to toggle bool when a question asked. so if a question asked, then "asked" bool will true and never seem in game. the questions asking as random. Is it possible make it?
public void ShowQuestions()
{
currentRoundData = dataController.GetCurrentRoundData();
questionPool = currentRoundData.questions;
questionIndex = Random.Range(0, questionPool.Count);
if (!questionPool[questionIndex].asked)
{
questionData = questionPool[questionIndex];
questionDisplay.GetComponentInChildren<TextMeshProUGUI>().text = questionData.question;
}
else{
questionIndex = Random.Range(0, questionPool.Count);
}
}
public void Close()
{
questionPool[questionIndex].asked = true;
}
Close method is a button method.
Answer by tormentoarmagedoom · Mar 14, 2018 at 09:06 AM
Good day.
Of course is possible. I recommend you to have all qiestions in an array. All question will have then a index number inside the array.
Then you only need to create another array, (lets call it infoArray) boolean type, with same lenght as questions array. Every time yo do somethig with a question, you must read/change the data in the infoarray. This way you can know if a question has been asked, or answered...
You can do more than 1 aditional array, one for the puntuation for each question, one to know if it has been asked or answered, etc..
Thats all multiple arrays sharing the index numbers. If need help with array scripting, look for some tutorials like this Bye! (If helped, accept the answer!)
O$$anonymous$$. but then, I have to declare it in Start $$anonymous$$ethod. So questions array have to be in ShowQuestions $$anonymous$$ethod. if i declare in each method, then the game can be problem. because the questions not come at start, I have a fortune wheel. fortune wheel co$$anonymous$$g randomly any categories and a question of came category will appear at screen. otherwise I did not get it enough
You can have a new script (class) with all the questions, and call this info when you need. You dont need to declare everywhere. Only once, and every script that needs the information, request the info at this new script.
I see you are littlw lost. $$anonymous$$aybe you should spend some hours with tutorials about basic scripting, to know how to use it.
You alse maybe need take a look what is a STATIC variable. All questions answers and info arrays should be static to easy acces from anywhere.
:D
I wrote RemoveAt() and I think it is solved. because the data already appear in script and removing there. it is not about editor. nevertheless, thanks.