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 pepe09 · May 25, 2018 at 09:43 AM · instantiateprefabandriodexport problem

Instantiate prefab does not work for Android

I'm working on a project with GoogleVR but I have a problem, when I run the app from the Unity editor the objects are created correctly but when I build it and run it on a cell phone with android it does not show me anything. This is the code to instantiate that I am implementing:

 GameObject sphereP = Resources.Load ("PrefabsTest/Sphere", typeof (GameObject)) as GameObject;
 sphere = Instantiate (sphereP.gameObject, transform.position, transform.rotation) as GameObject;


The name of my prefab is Sphere and the full path it is in is: "Resources/PrefabsTest/Sphere"


As I said before, in the unity editor it works correctly but at the moment of exporting it to a cell phone it does not show me anything, I have tried in several ways like to load the prefabs with public variables and then instantiate them and nothing works. I'm using unity 2018.1.1f1 and in the virtual reality SDKs i tried with cardboard and oculus.


I appreciate any help, thanks

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Edgor · Sep 09, 2018 at 04:53 PM

Okay, I had exactly the same issue as you described. In my game, there were 3 prefabs. They spawn after a trigger is activated. Now, in editor when the trigger is triggered, those 3 prefabs mentioned, do in fact spawn and I can see them and interact with them. Now on the other hand when I built the APK and ran it on the device, those 3 prefabs were no where to be seen. WEIRD. I went the extra mile by checking if the loaded GameObjects are null when the game tries to spawn. Nop, nothing. Apparently they were working.


Well, The issue was with the physics. You see, I found that the prefabs were spawning INTO the ground and not on the surface, the reason why they showed up correctly on the editor was because they glitched onto the surface. On the android, weirdly, they were glitching BELOW the ground and fell of off the world.


I realize that this might not be the case for everyone. In that way I recommend to make another simple prefab with nothing in it. Like a sphere. Make it a prefab, put it into "Resources" folder and try to spawn it in the world so you should definitely see it. It's unlikely that Unity would not do something without giving at least some sort of error message.

Good luck!

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 ediskrsmanovic · Sep 04, 2021 at 08:36 PM 0
Share

Life saver, thanks!

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

123 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 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

How do I re-instantiate original prefab after a game object inside has been destroyed? 2 Answers

[C#] How can I destroy instantiated prefabs when many are created with the same name? 2 Answers

Updating a variable on a script in an instanced object 1 Answer

Why is instantiated animator prefabs are not working properly? 2 Answers

[UNET] How to know the connectionID of a player ? 2 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