Uninomicon

Documenting the dark corners of the Unity Engine.

User Tools

Site Tools


scenemanager

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
scenemanager [2021/05/01 16:34]
73.95.178.156
scenemanager [2022/01/30 19:55] (current)
narry Added details about an undocumented quirk with occlusion culling in additive scenes
Line 39: Line 39:
 ===== Build Pipeline ===== ===== Build Pipeline =====
  
-Scenes are built during standalone in the following way: '+Scenes are built during standalone build in the following way:
  
   - The active scenes are closed.     - The active scenes are closed.  
   - Each Scene in the BuildSettings is opened. At this point prefabs are still prefab instances.     - Each Scene in the BuildSettings is opened. At this point prefabs are still prefab instances.  
-  - EditorSceneManager.sceneOpened callback is called.  +  - ''EditorSceneManager.sceneOpened'' callback is called.  
   - Prefabs in the scene are flattened (turned into normal game objects).     - Prefabs in the scene are flattened (turned into normal game objects).  
   - [[IProcessScene]] and PostProcessScene callbacks are called.     - [[IProcessScene]] and PostProcessScene callbacks are called.  
   - The final scene file is saved into the standalone build file.     - The final scene file is saved into the standalone build file.  
-  - Repeat for next scene+  - Repeat for next scene.
  
 ===== Sample Scene Load (Editor) ===== ===== Sample Scene Load (Editor) =====
Line 55: Line 55:
   * Prefabs.MergePrefabs (turning prefabs into gameobjects) happens before any other callback. (editor only)   * Prefabs.MergePrefabs (turning prefabs into gameobjects) happens before any other callback. (editor only)
   * Lightmapping is applied / loaded after Awake/OnEnable.   * Lightmapping is applied / loaded after Awake/OnEnable.
-  * SceneManager.sceneLoaded happens after PostProcessScene;+  * SceneManager.sceneLoaded happens after PostProcessScene.
  
 {{ :engine:unity_moxtvtiv0k.png?400 }} {{ :engine:unity_moxtvtiv0k.png?400 }}
Line 62: Line 62:
   * During a scene load (ie. Awake) the loading scene has ''scene.isLoaded=false''   * During a scene load (ie. Awake) the loading scene has ''scene.isLoaded=false''
   * During a scene unload (ie. Destroy) the unloading scene has ''scene.isLoaded=false''. ((You might expect during the unload phase that isLoaded=true, but this is not the case, even though all of the Scene objects are still perfectly loaded and accessible))   * During a scene unload (ie. Destroy) the unloading scene has ''scene.isLoaded=false''. ((You might expect during the unload phase that isLoaded=true, but this is not the case, even though all of the Scene objects are still perfectly loaded and accessible))
 +  * ''ISerializationCallbackReceiver.OnAfterDeserialize'' is called before the async loading of heavy scene resources (e.g. textures) so can be used for running scene-specific thread-aware code early in the loading process.((Unlike ''MonoBehaviour'' events which are called at the end.))
 +  * When using ''LoadSceneMode.Additive'', using the ''SceneManager.sceneLoaded'' callback and setting ''SceneManager.SetActiveScene(scene)'' within this callback results in Unity replacing the currently loaded occlusion culling data with the occlusion culling data from this newly loaded scene. [[https://docs.unity3d.com/Manual/occlusion-culling-scene-loading.html|This goes directly against what is documented, which states Unity will only use the culling data from the first loaded scene]]. This undocumented behavior has been tested in 2018.4-2020.3, and may or may not work in other versions of Unity.
  
  
Line 68: Line 70:
 ===== API Notes: ===== ===== API Notes: =====
 === SceneManager.sceneLoaded === === SceneManager.sceneLoaded ===
-  * Called *after* the loaded Scene Awakes.+  * Called **after** the loaded Scene Awakes.
  
  
    
scenemanager.1619886863.txt.gz · Last modified: 2021/05/01 16:34 by 73.95.178.156