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 /
avatar image
1
Question by nonameagan · Nov 01, 2013 at 06:32 AM · prefab

Loading prefab programatically

Hi, Actually i am newbie to unity3d. I tried to load prefab programatically, but the loaded prefab is not visible. here is my code,

gameObj = Resources.Load("sample", typeof(GameObject)) as GameObject; Instantiate(gameObj, transform.position, Quaternion.identity);

       Any kind of help to solve this problem is highly effective.Thanks in Advance.

regards, nonameagan.

Comment
Add comment · Show 4
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 sethuraj · Nov 01, 2013 at 06:41 AM 0
Share

Are you getting any error log when these lines are called..?Your resource 'sample' should be in a folder named Resources under Assets folder.

'Assets>Resources>sample'

The code is fine,dont change. Hope this helps...

avatar image robertbu · Nov 01, 2013 at 06:46 AM 0
Share

I tried your script, and it worked just fine:

 void Start() {
     GameObject gameObj = Resources.Load("Bullet", typeof(GameObject)) as GameObject;
     Instantiate(gameObj, transform.position, Quaternion.identity);    
 }

Check:

  • Check to make sure that your prefab is in the Assets/Resources folder.

  • Check to make sure the spelling of 'sample' is identical between the prefab and the script.

  • $$anonymous$$ake sure that the position of your object this script is attached to is visible to the camera.

  • $$anonymous$$ake sure it is not appearing inside of another object.

  • Check the hierarchy to see if the object is getting created at all.

avatar image robertbu · Nov 01, 2013 at 06:58 AM 0
Share

If it is in the hierarchy but not visible:

  • Check to make sure the position it is created at is visible to the camera.

  • Check to make sure it is enabled. If the prefab is disabled, then the created game object should be disabled.

  • Check to make sure the renderer is turned on. Again check the original prefab as well as the scene object.

  • $$anonymous$$ake sure it is not inside another game object.

  • $$anonymous$$ake sure it doesn't have a scale of (0,0,0).

avatar image nonameagan · Nov 01, 2013 at 10:58 AM 0
Share

Hi, $$anonymous$$ay i know whether the prefab is an 3D Object created using Blender.

I Check with all these ,but it is not visible in the scene.

regards, nonameagan.

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

17 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

Related Questions

Premade Texture Use 1 Answer

Show part of prefab on ui 1 Answer

Why do instantiated game objects not always render? 2 Answers

Prefab: Printing single letters of a word in UI Panel (one public variable different values) 2 Answers

Placing Prefabs in Prefabs. 9 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