Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Aug 31, 2015 at 09:12 PM by Ashky for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Ashky · Jul 04, 2014 at 09:55 PM · c#2dinstantiateprefabinvisible

Why is my instantiated prefab invisible ?

Hello, Unity Community!

I have this script attached to an empty game object:

     void Start () {
         _spawnPoint=GameObject.FindGameObjectWithTag("PlayerSpawn").transform.position;
         _selectedShape=PlayerPrefs.GetInt("shape");
         switch(_selectedShape)
         {
         case 1:
             Instantiate(Resources.Load("circleMC_prefab"),_spawnPoint,Quaternion.identity);
             break;
         }
     }

Basically, this should check what was selected in the previous scene, and according to that instantiate a specific prefab from my "Resources" folder, at a certain location determined by the "PayerSpawn" game object.

When I try to test it, the prefab is instantiated, I can see it in the editor, but it is invisible in the game! What's wrong ?

Comment
Add comment · Show 5
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 Kiwasi · Jul 04, 2014 at 10:15 PM 0
Share

Does the prefab have a renderer component attached and enabled?

avatar image Kiwasi · Jul 04, 2014 at 10:16 PM 0
Share

Also check that it is within the clipping planes of the camera

avatar image Ashky · Jul 05, 2014 at 07:19 AM 0
Share

Ha! Silly mistake by me. The prefab is getting instantiated at PlayerSpawn's position, with a Z=-10. Needless to say the camera didn't see it. I'll gladly vote this as the correct answer, if you want to post it as one. Thanks for your answer. Cheers!

avatar image Kiwasi · Jul 05, 2014 at 07:24 AM 0
Share

Have done. :)

avatar image Ashky · Jul 05, 2014 at 08:58 AM 0
Share

Great! ^ ^

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by Kiwasi · Jul 05, 2014 at 07:23 AM

Are you sure the GameObject is in view of the camera?

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
avatar image
0

Answer by Tanshaydar · Jul 04, 2014 at 10:18 PM

Instead of loading from Resources, I'd suggest to have GameObject list in your script and assign them to script (not the scene, but select the script in project view and assign the prefabs from there) and then instantiate them as gameObject_circle, _spawnpoint, Quaternion.identity

Comment
Add comment · Show 2 · 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 Kiwasi · Jul 04, 2014 at 10:21 PM 0
Share

This can be difficult to maintain in certain circumstances. In this case I don't think using the resources folder specifically is the problem.

avatar image Ashky · Jul 05, 2014 at 07:13 AM 0
Share

I can see how that would be the better option. However, I'm changing scenes often, without loading many prefabs, so it would just hinder my design process, in my opinion. $$anonymous$$aybe I didn't understand it properly.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Instantied 2D Prefab Is Invisible 1 Answer

How to move Instantiated 2D objects by 0.5 using arrows 1 Answer

The prefab you want to instantiate is null. 2 Answers

How do I make a clone of a prefab appear on the correct layer? [5.2.2f1] 1 Answer

How to generate different diagonal platforms? 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