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