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
0
Question by ronronmx · Aug 23, 2013 at 06:24 AM · instantiateprefabresourcesresources.load

Resources.Load() or Prefab manager?

I have a few Prefabs that I need to instantiate/use at runtime, and so far I have been using Resources.Load() to add them to the scene during gameplay.

But I was wondering if having a Prefab manager, present in every scene, would be a better idea. For example, I could set the number of Prefabs I will need for each scene, and drag&drop them in the Prefab manager in the inspector. That way, the Prefabs are ready and I can use PrefabManager.AddPrefab(myPrefab), which would instantiate a new copy, or perhaps from another class: GameObject prefabCopy = Instantiate(PrefabManager.prefab01)...

Is Resources.Load() slow? Not slow enough to worry about performance? What do you guys think?

Thanks!

Stephane

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
Best Answer

Answer by cdrandin · Aug 23, 2013 at 06:38 AM

Both Resources.Load and Instantiate are relatively slow, but a better solution could be to pool/cache your GameObject. Obviously at first you are going to need to Instantiate your object at least once, but if you have multiples of the object in your scene and these objects are recurring. When said object is no longer needed you simply "hide" it and move it away from the scene and then when an object of that type is needed you simply show it back again and the object will start up like before, this depends on how you set up your scripts.

This way is far less expensive and not at all hard to manage.

Edit: With your gameobject and you could even create its own Instantiate function which takes whatever parameters needed that will re-position it to where it is needed and make sure to reset variables if need be, example an enemies health back to 100 instead of its dead state (0 hp).

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 ronronmx · Aug 23, 2013 at 11:06 PM 0
Share

Thanks for the quick answer cdrandin!

The only time I currently use Resources.Load() is during setup (Start/Awake) or when I need to display an on-screen message to the player, for example, I use a custom SR$$anonymous$$essage.Show$$anonymous$$essage(...) function which uses Resources.Load() to load a HUD$$anonymous$$essage Prefab into the scene, and then destroys it a few seconds later.

Considering this, I don't think a pool manager would be a benefit. I am developing for IOS/Android platforms, and I don't know if Resources.Load() is the better option there. Are there any issues concerning the use of Resources.Load() on mobile devices?

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

15 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

Related Questions

Resources.Load doesn´t work! 1 Answer

Some weirdness with recursive instantiation. 2 Answers

Prefabs are instantiated in editor but not in executable 2 Answers

Eliminating prefabs from resources folder? 1 Answer

How to get unique reference to instantiated prefab 1 Answer


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