[Unity-24] Four ways to load scenes from unity

Source: Internet
Author: User

Unity officially provides 4 ways to load scenes (scene), respectively:
1. Application.loadlevel (): Synchronous loading
2. Application.loadlevelasync (): Asynchronous load
3. Application.loadleveladdictive (): Synchronous add-on loading
4. Application.loadleveladdictiveasync (): Asynchronous add-on loading

The following four methods are presented and analyzed briefly:
1. Synchronous loading: Assuming that the current scene is a, we are going to switch to the scene b,unity all the contents of scene B (all static objects in scene B, excluding objects instantiate instantiated in the subsequent code) are loaded into memory when the scene is switched. Then destroy A, show B. Because load B is synchronous (that is, in a thread), performing this method will feel stuck when the b scene is large.
2. Asynchronous loading: This is basically the same as the first case, the only difference is that the process of loading B is asynchronous (that is, the behavior of loading a new scene is in a background thread, without affecting the running of the main thread), so that the current scene A is not affected and can continue to run when loading B. So even if scene B is large, it doesn't feel like a lag.
3. Synchronous add-on loading: Assuming the current scene is a, we will load the scene b,unity will not destroy a when loading B, that is, A and B will exist at the end of the load, this is suitable for the world map is relatively large, Dynamically load different parts of the world map according to where people go. The premise, of course, is to make the world map into several different scene files.
4. Asynchronous add-on: This is the same as the previous one, where the difference is still that the process of loading B is asynchronous in a background thread.

Note: The most important application of asynchronous loading is to make the transition interface during the scene switching process. Specific methods can be found in the rain of the Big blog. Address: http://www.xuanyusong.com/archives/1427/

[Unity-24] Four ways to load scenes from unity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.