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
4
Question by kretchfoop · Dec 11, 2011 at 04:09 AM · instantiateprefabcomponents

Instantiated prefab loses components

I instantiated a prefab in a script. The GameObject that is created doesn't have any of the components from my prefab in the project view. My prefab is suppose to have a rigidbody and a box collider but when I instantiate it it has neither. I tried just creating them and setting them to the ones they should be but it's telling me the value I am trying to take them from is a read only variable(a global variable set to a gameobject in project view). I tried creating the whole thing in the script but then I couldn't find a way to edit the box collider size and center variables. A way to do that would allow me a work around but a solution to the problem of the prefab losing its components would be ideal. Sorry if this question appeared somewhere else but I looked and couldn't find it.

Comment
Add comment · Show 1
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 ByteSheep · Dec 11, 2011 at 09:44 PM 0
Share

That's strange, never had that problem before. I'm guessing you have the prefab in the project window that has all the components attached. If you add this to your hierarchy by dragging it, are the components attached to the game object? The game object in the hierarchy should have blue (ins$$anonymous$$d of black) text..

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by kretchfoop · Dec 13, 2011 at 07:26 AM

I was trying to instantiate it using a script with it as a variable in the script (in the project view). I got around it with kind of a hack job of making an actual version of the prefab in the hierarchy off camera and instantiating that. Seems to be working fine.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

prefab is instantiating without a script 2 Answers

Instantiated Prefabs Not Showing Components 1 Answer

Changing LocalScale in code affecting prefab stored in Assets 1 Answer

Instantiate a prefab vs create one dynamically at runtime? 1 Answer

Spawning a prefab at another object's location 3 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