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 /
avatar image
0
Question by filerjosh · May 22, 2018 at 10:36 AM · android buildlists

List.add() causing issues on android build

Hello. So i have recently started having errors on the android build that don't appear when testing in the inspector. The setup i have is a button and when it is pressed i want it to add the name of a sprite to a list. I also have another button which removes the name of a sprite from the list. Both of these functions work in the inspector and no errors come up in the console related to it. However, when ran on my phone when built to android, neither of the functions allows the value to be added to the list and wont allow me to interact with the list.


What should happen when button is pressed (What happens in the inspector when the button is pushed):

alt text


alt text


Starting Code to do with list

 public List<string> FavouriteBoardGames;
 
 private void Start()
 {
         ScenceName = SceneManager.GetActiveScene().name;

         if (ScenceName == "Libary")
         {
         FavouriteBoardGames = new List<string>();
         LoadFavBoardGames();
         }
 }

The code for adding to the List

 public void AddToFavourite()
     {
         string name = image.GetComponent<Image>().sprite.name;
         Favoruite.SetActive(false);
         UnFavourite.SetActive(true);
         FavouriteBoardGames.Add(name);
         SaveFavourites();
     }

The code for removing from the List

  public void RemoveToFavourite()
     {
         string name = image.GetComponent<Image>().sprite.name;
         Favoruite.SetActive(true);
         UnFavourite.SetActive(false);
         FavouriteBoardGames.Remove(name);
         SaveFavourites();
     }

I've moved the order of the code around to test on the android build what it crashes on. On the build, it runs up to FavouriteBoardGames.Add(name); doesn't do that and doesn't carry on to save the information. The name of the board game isn't null and returns the correct value on the android build (i put a UI text on the screen and changed the text to be the name of the sprite name and it worked).

4.png (4.0 kB)
2.png (2.9 kB)
Comment
Add comment · Show 2
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 dev-waqas · May 22, 2018 at 11:01 AM 0
Share

Are you sure that your scene name is library on android? Which is checked here.

          if (ScenceName == "Libary")
          {
          FavouriteBoardGames = new List<string>();
          LoadFavBoardGames();
          }

avatar image filerjosh dev-waqas · May 22, 2018 at 11:46 AM 0
Share

alt text That is the name of the scene (in my bad spelling) which matches up with the check of the scene name. I also put a Text UI element into the secene and put this in the if statment:

 if (ScenceName == "Libary")
         {
             FavouriteBoardGames = new List<string>();
             LoadFavBoardGames();
             debug.text = "Loaded";
         }

and the text changed when the correct scene was loaded (Just to be on the safe side lol)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by filerjosh · May 23, 2018 at 01:49 PM

Anyone Got any idea whats wrong?

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 dev-waqas · May 23, 2018 at 07:45 PM 0
Share

As far as I think List.add() is not causing any issue because it is so much basic functionality we use every day. It is some other issue may be complete scripts might help. $$anonymous$$oreover one mistake could be not setting up correct execution order. See this for more info.

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

86 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

Related Questions

Need help with an issue regarding lists (I think). 1 Answer

Disable Weapons Until Bought FPS Creator Kit 0 Answers

Audiosource list empty? 0 Answers

touch control doesn't work right after suspending and resuming game 0 Answers

Export to google Android Project 0 Answers


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