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 /
avatar image
1
Question by Doghelmer · Jan 12, 2016 at 05:23 AM · scenescene-loadingscene-switchingscene-changescene load

Most efficient way to transition between scenes?

I'm a little confused on what's going on with Unity when I load a new scene, and I'm not really sure what the best practices are for keeping memory usage and load times down.

At the beginning of each of my scenes, I'm using Resources.Load to load a lot of different prefabs into memory. Many of these are repeated between the different scenes. Is it better to store these as prefabs in a "DontDestroyOnLoad" object and just reference them this way rather than use lots of Resources.Loads in each scene? Or does this not make much of a difference?

I also have to instantiate a lot of objects at runtime at the start of a level due to the game world being procedurally generated. This takes a bit of time to load. Would there be some way to keep this stuff in memory and place them into a new level more quickly, maybe using a pooling system?

Furthermore, is there anything else you'd recommend that I do when entering a new scene to ensure that it loads more quickly and keeps memory usage down?

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 ashleyjlive · Jan 12, 2016 at 10:38 AM

Forgive me if I'm wrong but I believe Unity cleans up the memory on objects which aren't marked as "DontDestroyOnLoad" using a garbage collector every time you load a scene (provided it isn't additive scene loading when then everything in the current scene is marked as don't destroy on load). Given this, you can get away with just loading them into memory each time you load a scene but it is far better just to pool them (this does not decrease/increase memory usage but instead improves load times). Therefore, it is better to load them only once and mark them as "DontDestroyOnLoad" if load times is what you are aiming for. If you are mainly focused on memory usage then do not pool these objects and instead just create them when necessary.

To keep memory usage down, ensure that you compress textures and use appropriate filtering on objects in your scene.

Feel free for anyone to correct me if I'm wrong.

Comment
Add comment · Show 2 · 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 Doghelmer · Jan 13, 2016 at 08:57 PM 0
Share

This seems pretty accurate. I also posed the question on Reddit, and one of the commenters confirmed what you said here.

avatar image 017Bluefield · Nov 27, 2016 at 07:45 AM 0
Share

Excuse me, but which version of Unity was active when this question was asked (on January 12)? Context might help some 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

36 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

Related Questions

Unity Scene loading problem (slow loading until it freezes) 0 Answers

Is there any ideas to load Unity scene asynchronously? 1 Answer

One Location Game (with Scenes Loaded and Disabled) 0 Answers

Scene Loading takes over 3 minutes 1 Answer

Old scene still appears for short time when switching scene 0 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