Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
2
Question by MadDave · Aug 22, 2012 at 09:34 AM · optimizationprefabsloadingasync

Instantiate many Prefabs / Async Loading

Hi,

I am aware that there are already many questions and answers related to async level loading, but none of these really satisfy me. So here we go:

I am working on an MMO-style game. The world is pretty dynamic, so instead of using unity scenes we create game areas at run-time. This means that a) dozens of prefab resources get loaded b) thousands of prefabs get instantiated

For large areas this takes some time. Now I would like to have an animated loading screen and I don't want to lock up the main thread for several seconds anyway.

Surprisingly, instantiating the objects takes A LOT longer than the actual resource loading. It is much faster in a real build than in the editor, though.

Question 1: Are there tricks to speed up the instantiation process? Batch-Instantiate or something like that? It seems strange that it should take so long.

Question 2: Is there a way to put the loading/instantiating in a background thread? Basically I want my own version of LoadLevelAsync(). I already considered using the Fiber-like logic of CoRoutines, has anyone already tried something like that?

Thanks!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by MadDave · Nov 07, 2012 at 06:50 PM

Since this question still receives views but no answers I'll quickly describe how we solved it. May not be the best solution but works for us so far:

We put all objects to be instantiated in a list. A CoRoutine works its way through that list and yields after a fixed time limit, continuing in the next frame. This allows us to draw a progress bar and do network updates during level loading.

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 MacSecrest · Dec 11, 2012 at 08:02 PM 0
Share

Thanks for the update to your own question. I too am looking for Async Instantiate. I need not so many items to load in very fast but also not lag the current game at all. I might make a list similar to yours and have the LoadNextItem be based on deltaTime.

I wonder if I could load in parts of an Object over time, such as; if (deltaTime < 0.02) load 1% of Item X per frame.

Thanks for your reply anyhow, it helped.

avatar image
0

Answer by HexGrimm · Jan 11, 2018 at 09:00 AM

@MadDave I think you can use Scene.AsyncLoad (Additional Load) method to reach your target. I guess it is possible to combine scenes with prefabs linked, so they represent pool of instanced reusable objects. But I am not sure about shaders prewarm and initialization phase that can increase your frame time. It usually happens because some Unity default components do a big work on Awake, which process in main thread context.

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 jpgordon00 · May 30, 2021 at 10:21 AM

I created a solution to load any amount of prefabs async with callbacks, timers and more.

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

10 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

Related Questions

Confusion about DontDestroyOnLoad and very large scenes... 1 Answer

How to have 2 sets of textures and make sure only one is loaded? 0 Answers

Long load time for scene... Some optimization questions. 1 Answer

Loading a level and some resources asynchronously 0 Answers

LoadLevelAsync coroutine reloads level repetedly 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