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 /
  • Help Room /
avatar image
0
Question by krazykhris875 · May 19, 2016 at 09:52 PM · androidbugstroubleshootingadvice

Instantiated GameObject is Invisible on Android -- But is Visible in Inspector (Should be Visible)

Hey guys. I really need some help. I released my first game on Android about two weeks ago (woohoo), and today I sat down to start working on the second update, which was meant to fix a bug and make the game load a bit faster.

My game is simple. You squash flies that fly around the screen. If you miss, you lose, if you hit it, you get a point and another one instantiates.

So today I got to work, fixed the bug (which was that the game never initialized if the user had disabled the sound in the game, it was a quick fix.

Then I set out to make some animations faster. These animations occur every time the user loads a scene (one animation before load, one after), so making them faster wasted less of the users time. Done.

Then the game broke. At some point hit Build & Run, and it came up on my phone with no fly. I've spent the past 2 hours or so trying to fix it. The problem is that it works perfectly in the editor. Running the game on my computer is no problems at all, but as soon as I build it to my phone, it all goes to hell.

I'm at a bit of a loss for how to even troubleshoot this. I know that the game is technically doing everything except for showing me the actual fly. When I start the game, everything that's supposed to happen does, and if I click the screen, it triggers the failed game that you get when you miss the fly. I've also made use of the debug log and the adb logcat -s Unity command, and using that was able to determine the fly absolutely DOES get instantiated and DOES exist in the game (aside from things in the game happening that the fly controls). So I'm 100% positive it's there. I just don't know where.

This is the code I was using to instantiate it to a random spot on the screen (camera is fixed in this game, doesn't move):

         Vector3 screenPosition = Camera.main.ScreenToWorldPoint(new Vector3(Random.Range(0, Screen.width), Random.Range(0, Screen.height), 15));
         GameObject newFly = Instantiate(flyPrefab, screenPosition, Quaternion.Euler(0, 0, 0)) as GameObject;
         newFly.transform.SetParent(MainMenuGameObject.transform);
         newFly.transform.localScale = new Vector3(0.07495514f, 0.07495514f, 0f);

In an effort to get a handle on things, I changed it from a random spot to 0, 0, 0, like so:

     Vector3 screenPosition = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 15));
     GameObject newFly = Instantiate(FlyPrefab, screenPosition, Quaternion.Euler(0, 0, 0)) as GameObject;
     newFly.transform.SetParent(MainMenuGameObject.transform);
     newFly.transform.localScale = new Vector3(0.07495514f, 0.07495514f, 0f);

This, too, works fine on my computer, with the fly starting in the same spot every time, but on my phone it's just invisible still. I'm not getting any errors, and I've really no idea what's wrong.

ONE MORE IMPORTANT THING:

I tried manually dropping a fly prefab into the scene before building it to my phone. I put it in the scene, made it a child of MainMenuGameObject, and set the scale to the same as above. Loaded up the game on my phone, and THAT fly was there. So the prefab is apparently fine. My money is on it somehow being created outside the camera but I've no idea how.

Is there any way to get the scene view in unity hooked up to the instance running on my phone so I can see where the fly is? Any other ideas? I'm at a total loss here. I've done as much troubleshooting as I can think of, but I've run out of ideas to fix this.

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 corn · May 19, 2016 at 11:51 PM 0
Share

Are your flies 3D models ? There's a bug concerning animation and rotation of 3D models in Android builds with 5.3, so if that's the case for your flies check this forum thread on the subject.

If that's not the case, you should log the flies' positions (and maybe scales too) so that you can at least know where they are in the scene

avatar image krazykhris875 corn · May 20, 2016 at 08:11 PM 0
Share

Thanks! I did get it working, see my answer for how. I appreciate your help! And to answer your question, it was a 2D sprite on Android 6.0. Very weird bug.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by krazykhris875 · May 20, 2016 at 08:10 PM

This was a weird bug. I've got a script that modifies the camera some for scaling/positioning on different devices, it seems that what caused this bug must have been that script not having run yet, as what fixed it was ultimately just making the fly instantiate slightly after the start of the scene, instead of on awake. Weird about it working in editor, though. I guess it's just something about the way Android processes. Thanks for your help.

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

79 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

Related Questions

Why is Unity automatically changing the current platform? 0 Answers

Android how to set version to 1.1 0 Answers

Simple project on Android: Builds correctly, runs on device, but it is very buggy. 1 Answer

Windows 10 debug differs from android build 1 Answer

Android Project Split Build Troubles 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