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 Scej · Sep 01, 2016 at 06:45 PM · prefabgameobjectsinstantiation

Advantages of instantiating prefab vs gameObject?

Pretty simple question, what are the advantages if any of instantiating a prefab vs an existing inactive gameObject?

I personally find using gameObjects to be easier, I can tweak them to my liking while they're in place such as child UI element, and just set them to inactive until I'm ready to use them. When I instantiate all I have to do to the clone is match its hierarchy parent to the original and set it as active.

Prefabs on the other hand, if there are any modifications that require the prefab to be in it's place, I have to manually place it where it will be in the hierarchy to make changes, apply my changes and delete it from the hierarchy. Additionally placing it properly back into the scene hierarchy on instantiation is a chore.

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 etaxi341 · Sep 01, 2016 at 07:07 PM 0
Share

Well actually just activating is pretty good because it won't lag your game on activating as much as instantiating a new gameobject. But it has also some bad sides. If you have to many GameObjects (even if inactive) the game will use more RA$$anonymous$$. so if you want to use less RA$$anonymous$$ you should instantiate. If you want to have performance you should just reactivate the GameObjects.

avatar image ScaniX · Sep 01, 2016 at 07:12 PM 0
Share

I guess the advantage of a prefab is that they all reference the same source components and only store the locally changed values in the instances.

That way if you use a pretty complex GameObject with lots of components, properties or containing a hierarchy of other GameObjects, you can just change the components, properties or hierarchy in the prefab and all instances in all your scenes (as long not locally overridden) will update to it.

I am mostly using prefabs if I have the slightest feeling that I will reuse it somewhere. In rare cases, I am also using local "offscreen" GameObjects, that I assign as pseudo prefabs to my scripts to instantiate.

I have to agree that editing is sometimes a pain. You can edit the properties of all first level children of the prefab, but have to temporarily add it to the scene to do changes to deeper children or the hierarchy. Still I learned to live with this and think prefabs are a very useful thing. :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ArturoSR · Sep 01, 2016 at 07:14 PM

Hi, OK, the advantage between an original and an instance is as follows:

  1. The game object (prefab) could be part of a pooling system, this allow less process for the application when you only "moves" the dead object to another location and set it alive again.

  2. The instance is a "copy" from a prefab, you can generate many copies as you need them but can have a cost about processing frames, normally you use this case with particle FXs (appears, do his job and die) and must not leave any trace about it (memory space).

So, this is the more simply explanation about advantages from an original of a prefab and an instance from a prefab, but essentially both are "instance" from a prefab, only the use of each one changes, cheers.

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

65 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

Related Questions

How can i define a costume function for an object in a prefub that I spawn? 1 Answer

Problem Instantiating a Prefab 1 Answer

GameObject created from Prefab, much larger than original object 0 Answers

GameObject spawning at several Y distance below my spawn point 0 Answers

Switching out GameObject with Prefab? 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