Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by andrewflippo · May 11, 2015 at 07:35 AM · dynamic

Changing dynamic toggle.isOn in List

I'm pretty deep into this program. I have 4 columns of toggles dynamically created. The user selects one from each column. Those selections are saved into their own lists. The linking list is the roomTrackList. so on the next panel it lists the users choices loading from each List. They are tracked by sharing the index with the roomTrackList.

My problem: When switching back to the Choice Panel I want to select other choices, then select the room again and hit a load button. It then takes all the toggles in each column and resets them to the choices previously saved in each array.

I'm currently trying to compare the text of the toggles to the text in the array then take the toggle component and switching the isOn. It errors on me error CS0029: Cannot implicitly convert type string' to bool'

My code:

 for (int i = 0; i < roomTrackList.Length; i++) {
             // Check is Room is selected
             if (roomTrackList[i].GetComponentInChildren<Toggle> ().isOn == true) {
                 // Check is RoomArray is = to the Room Selected
                     if (RoomArray[i] == roomTrackList[i].GetComponentInChildren<Text>().text)
                     {
                         Pet_Name.text = PetArray[i];
                         Owner_Name.text = OwnerArray[i];// need to set it equal to the one in the array.
 
                         for (int n = 0; n < techTrackList.Length; n++)
                         {
                             if (TechArray[i] = techTrackList[i].GetComponent<Text>().text)
                                 techTrackList[i].GetComponent<Toggle>().isOn = true;
                         }
                         for (int n = 0; n < doctorTrackList.Length; n++)
                         {        
                             if (DoctorArray[i] = techTrackList[i].GetComponent<Text>().text)
                                 doctorTrackList[i].GetComponent<Toggle>().isOn = true;
                         }
                         for (int n = 0; n < statusTrackList.Length; n++)
                         {
                             if (StatusArray[i] = statusTrackList[i].GetComponent<Text>().text)
                                 statusTrackList[i].GetComponent<Toggle>().isOn = true;
                         }
 
                     // Check is RoomArray is not equal to RoomTrackList text then
                     } else if(RoomArray[i] != roomTrackList[i].GetComponentInChildren<Text>().text)
                         {
                         
                             foreach (GameObject temp in techTrackList)
                             {
                                 if (TechArray[i] = techTrackList[i].GetComponent<Text>().text)
                                     techTrackList[i].GetComponent<Toggle>().isOn = false;
                             }
                             foreach (GameObject temp in doctorTrackList)
                             {        
                                 if (DoctorArray[i] = techTrackList[i].GetComponent<Text>().text)
                                     doctorTrackList[i].GetComponent<Toggle>().isOn = false;
                             }
                             foreach (GameObject temp in statusTrackList)
                             {
                                 if (StatusArray[i] = statusTrackList[i].GetComponent<Text>().text)
                                     statusTrackList[i].GetComponent<Toggle>().isOn = false;
                             }
                         //techTrackList[i].GetComponent<Toggle>().isOn = false;
                         //doctorTrackList[i].GetComponent<Toggle>().isOn = false;
                         //statusTrackList[i].GetComponent<Toggle>().isOn = false;
                     }


Im at a loss of any other way to do it. Any help would be appreciated.

Link to a screenshot to get an idea of what I'm trying to do.link text

Comment
Add comment · Show 3
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 Baste · May 11, 2015 at 08:16 AM 0
Share

You need to post the line that's throwing the error. From the image you posted it's 302, but you're posting from the middle of your file, so I can't tell which one it is.

avatar image Mehul-Rughani · May 11, 2015 at 08:52 AM 1
Share

you need to use == ins$$anonymous$$d of = in all the if statements.Hope it works :)

avatar image andrewflippo · May 11, 2015 at 03:54 PM 0
Share

Oh man. Thank you. After 10 hours I was just too close to it and fatigued to see it. It's the old VB coding that's confusing me. Thank you for pointing out that and thankfully it was that easy.

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

C# How to make String Dynamic for UnityEvent 0 Answers

Creating one-way platforms with dynamic colliders in a 2D vertical platform jumper 0 Answers

Applying behaviour from weight texture mapping 0 Answers

How to access the data in a list that save any class inside 1 Answer

Changing game object based on variable state? 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