• 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 /
avatar image
0
Question by Rgalaxy · Jan 23, 2014 at 01:36 AM · javascriptguiarrayflag

Giving a flag for Array

Holla, i try to find out how to do this, maybe not actually giving a flag to array but i can't think the proper name of my problems.

Basically i want to create an array to random textures which is in my case will be a texture of "Math problems".. so the Textures must each contain with the answer, ex : a, b, c.

i create a GUI that have a button of A B C, so when the player press A it will check the value of texture is now a,b, or c.. is that possible? i mean i know it's possible but i couldn't find out how.. some pointer will be appreciated :) Thanks before

Comment
Add comment · Show 1
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 HappyMoo · Jan 23, 2014 at 08:56 AM 0
Share

As far as I understood, you're making a quiz. Each question is not text, but a picture that includes the question + all possible answers labeled A-C. Now what's the problem again? Where to store the correct answer? Do you want to store that also in the picture?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jaroosh · Jan 23, 2014 at 09:01 AM

by ckecking the value of text do you mean in the array (in code) or on screen ? if on screen you can just set some border and in the code you can keep a separate bool array to mark which answer is selected (i.e. if you have array with Texture[ATex, BTex, CTex] then you have boolean[1,0,0] where 1 denotes checked) or even better you can have an array of some structs like :

 struct Answer {
   Texture tex;
   bool isChecked;
 }

and keep a list of those List instead of an array of textures. You can then use Linq to query this array like :

 var selected = AnswersList.Where(l => l.isChecked);

which will return all selected.

Comment
Add comment · Show 1 · 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 Rgalaxy · Jan 23, 2014 at 04:51 PM 0
Share

in code. so now i have var texture : Texture[] (which i put 20 on Inspector, and put 20 texture on it) then i just make it become var texture : Texture[1,2,3,1,2,3,3,2,1,2,2,1,3,etc] ??

i read that i must avoid Linq? although i dont clear why it must be avoided :3

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

20 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

Related Questions

Arrange ints from biggest to smallest and display them in a table 1 Answer

More like a bulletin than chat box 0 Answers

Multiple enemy indicators 2 Answers

How can i show the texture in the array? 2 Answers

Setting Scroll View Width GUILayout 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