Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by freedom667 · Mar 14, 2018 at 08:30 AM · unity 5arrayeditor-scriptingbooleanrandom.range

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?

My GameDataEditor

 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.

ekran-resmi-2018-03-13-183230.png (189.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

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!)

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image freedom667 · Mar 14, 2018 at 09:22 AM 0
Share

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

avatar image tormentoarmagedoom freedom667 · Mar 14, 2018 at 09:33 AM 1
Share

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

avatar image freedom667 tormentoarmagedoom · Mar 14, 2018 at 12:17 PM 0
Share

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.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

168 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

If ALL in boolean Array = true ... else ... 3 Answers

How to edit Properties of a ScriptableObject asset, specificly arrays/lists 0 Answers

how to not repeat random array 1 Answer

How to change a game objects tag after it has been randomly selected? 0 Answers

List<> problem 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges