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 berkc · Apr 24, 2016 at 08:05 PM · prefabbuildsprite

Editor Works, Build Not

In my game, I have public GameObject prefabs and in a script I change their sprites. It works perfectly in editor but it fails when I build it. I checked output_log file and everything seems fine. I debugged names of sprites and prefabs, they are not null and have correct values. How can something which works fine in Editor doesn't work when I build it?

Comment
Add comment · Show 8
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 abduomar · Jan 11, 2017 at 05:50 PM 0
Share

I am facing the same problem.Did you fix it?

avatar image berkc abduomar · Jan 11, 2017 at 06:36 PM 0
Share

Unfortunately I couldn't fixed it so I tried different methods to change sprites.

avatar image abduomar berkc · Jan 11, 2017 at 06:55 PM 0
Share

@berkc Is it really a Unity bug?

avatar image LK84 · Jan 11, 2017 at 06:32 PM 0
Share

This can have multiple reasons. One reason is that preprocesser directives (something like #if UNITY_EDITOR, UNITY_ANDROID etc.). are in the code. Another reason might be unsafe code (like imported native DLL) which won't run on a Android/IOS build. But without seeing your code I just can guess.

avatar image berkc LK84 · Jan 11, 2017 at 06:37 PM 0
Share

I tried it on a new project without importing anything. I think its a Unity bug.

avatar image abduomar LK84 · Jan 11, 2017 at 06:41 PM 0
Share

@L$$anonymous$$84This is my code :

  public Sprite[] sprites;
     public Button button1;
     public Text price1;
     public Image lockedPrice1;
     public Image characterImage1;
     
     public bool isUnlocked1;
     public bool isChosen1;
     
     public void OneHundred()
     {
         t.text = coinCounter.ToString();
         if (coinCounter >= 100 && isUnlocked1 == false)
         {
             int coinTotal = coinCounter - 100;
             PlayerPrefs.SetInt("Coin", coinTotal);
             price1.gameObject.SetActive(false);
             lockedPrice1.gameObject.SetActive(false);
             characterImage1.gameObject.SetActive(true);
             isUnlocked1 = true;
             PlayerPrefs.SetInt("Unlocked1", 1);
             PlayerPrefs.SetInt("Chosen1", 0);
         }
          else if ( isUnlocked1 == true && isChosen1 == false)
         {
     
             ball.GetComponent<SpriteRenderer>().sprite = sprites[1];
             Scene$$anonymous$$anager.LoadScene("$$anonymous$$ain $$anonymous$$enu", LoadScene$$anonymous$$ode.Single);
             isChosen1 = true;
             PlayerPrefs.SetInt("Chosen1", 1);
             PlayerPrefs.SetInt("Unlocked1", 1);
         }
          else if(isChosen1==true)
         {
             Scene$$anonymous$$anager.LoadScene("$$anonymous$$ain $$anonymous$$enu", LoadScene$$anonymous$$ode.Single);
             ball.GetComponent<SpriteRenderer>().sprite = sprites[1];
         }
         t2.text = PlayerPrefs.GetInt("Coin", 0).ToString();
         t.gameObject.SetActive(false);
         t2.gameObject.SetActive(true);
     }


avatar image abduomar LK84 · Jan 11, 2017 at 06:44 PM 0
Share

$$anonymous$$y point is when the player wants to buy another character i want the freshly bought one(sprite) to replace the deffault sprite.On editor it works great but on Android or IOS it just doesn't change. Thanks in advance ;)

avatar image berkc abduomar · Jan 23, 2017 at 12:27 PM 0
Share

It is difficult to test it without actual project. In last "else if" block, you are loading scene then changing sprite of ball. $$anonymous$$aybe it works well on editor but on Android it loads it and can't change the sprite after. I suggest you to swap those lines, first change sprite then load the scene.

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

6 People are following this question.

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

Related Questions

Distribute terrain in zones 3 Answers

Disfigured sprite after build. 0 Answers

Is it possible to create / replace prefab in builded game? 1 Answer

Loosing sprite association when transferring prefab 1 Answer

Overlapping objects increase drawcalls in 2DToolkit 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