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 H-Rat · Aug 24, 2015 at 11:27 AM · android2duiunity5no errors

a function is working on editor but not working on android divice

Hi I'm using unity 5.1.1 and my 2D game is fully work's on editor but one of my function is not working in android and it just skip other onClick jobs on my UI button. this button is doing several things but i checked when it calls that function, jobs after that are skipping and the function it self is not doing anything. my function is :

 public void InventoryUpdate()
         {
             i = 0;
             foreach(Transform child in transform)
             {
                 Destroy (child.gameObject);
             }    
     
             foreach(var key in myDicObjects)
             {
                 string keyname = key.Key;
                 int keyNumb = key.Value;
         
                 if (keyNumb != 0)
                 {
                 inDicObj = GameObject.FindGameObjectWithTag (keyname);
                     gameObjectsDic[keyname] = inDicObj;
     
                     //create a new item, name it, and set the parent
                     newItem = Instantiate(itemPrefab) as GameObject;
                     newItem.name = keyname + " item at (" + i + ")";
                     newItem.transform.SetParent(gameObject.transform);
                     
                     //set number of obj
                     newItemNumb = newItem.GetComponentInChildren<Text>();
                         
                     
                     //move and size the new item
                     rectTransform = newItem.GetComponent<RectTransform>();
                     rectTransform.localScale = new Vector3(1,1,1);
     
                     containerTemp.x = myDicObjects.Count * 100;
                     containerTemp.y = containerRectTransform.sizeDelta.y;
                     containerRectTransform.sizeDelta = containerTemp;
                     
                     // position inventory stuff
                     temp.x = ((-containerRectTransform.sizeDelta.x / 2)+50)+(i*100);
                     temp.y = (containerRectTransform.sizeDelta.y / 5);
                     rectTransform.offsetMin = rectTransform.offsetMax = temp;
                     rectTransform.sizeDelta = new Vector2(100,100);
                     
                     //set itemPrefab values
                     prefabSprite = gameObjectsDic[keyname].gameObject.GetComponent<SpriteRenderer>();
                     itemImage = newItem.transform.Find("Image").GetComponent<Image>();
                     itemImage.sprite = prefabSprite.sprite;
                     
                     InventoryManager invenManager = newItem.gameObject.GetComponent<InventoryManager>();
                     ObjController objController = gameObjectsDic[keyname].gameObject.GetComponent<ObjController>();
                     invenManager.objValue = objController.objValue;
                     invenManager.sliderTag = objController.sliderTag;
                     invenManager.objXp = objController.xpValue;
                     i++;
                     newItemNumb.text = keyNumb.ToString();
                 }
             }
         }

any Idia??!!!!

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 Tonks · Aug 25, 2015 at 03:39 PM 1
Share

Have you set up a number of debug logs throughout to see if each step of the code is calling? It can help you identify if one line is having an issue (certain things in Unity wont work on Android and/or iOS).

Additionally, do yourself a favour and convert those foreach loops into for loops. foreach loops can cause a memory leak with Unity and you don't want that :)

avatar image Zoelovezle · Aug 25, 2015 at 08:22 PM -1
Share

Can you Explain what part of you function is particularly not Working ..

1 Reply

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

Answer by H-Rat · Aug 25, 2015 at 08:22 PM

i changed the second dictionary to a list and i can loop throw it now on both editor and android and it solved my problem, but I'm steel wondering why i couldn't use dictionary.I debugged it and find out when ever i tried too loop over a dictionary it 's not working on android device and dictionary.count was have same problem. Is it a BUG??? because it's working on editor without any error...

Comment
Add comment · 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

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

buttons not working in android. 1 Answer

Problem with UI input field in android 1 Answer

why unity IPA file size increased after installation as compare to unity APK? 1 Answer

[5.4 - Unity2D - Android] UI Button Requires Child Text? 0 Answers

Scroll Rect Content Disappearing (Video) 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