scenemanager
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
scenemanager [2021/02/07 23:55] – uninomiconadmin | scenemanager [2025/01/15 04:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | #SceneManager | + | ====== |
- | Notes: | ||
- | `SceneManager.sceneLoaded` is called *after* the loaded Scene Awakes. | + | ==== When does scene loading happen? ==== |
- | Scene Loading always | + | Scene loading and unloading |
- | The Unity scene flushing pipeline works differently in the initialization phase of the player. | + | Player Loop Phases: |
- | Scene loads thats are queued during initialization are blocked and fully loaded before the game starts. | + | * __Initialization__ (Scene Loading happens here) |
- | For example, if SceneManager.LoadSceneAsync is called in the Awake of the very first scene (ie. called before the first Update), then the engine will wait to fully load that scene as well, before starting the first Update. | + | * Game Loop |
+ | * Early Update | ||
+ | * __UpdatePreloading__ (Scene Loading happens here) | ||
+ | * FixedUpdate | ||
+ | * Update | ||
- | It is untested if this is also the case for SceneManager.UnloadSceneAsync. However, because Unity documentation mentions that that the scene | ||
- | loading queue is a pipeline, and only one AsyncOperation can progress at a time, I would suspect that the Engine simply " | ||
- | during initialization. | ||
- | Phases: | + | ===== The Scene Loading |
- | - Initialization (Scene Loading | + | |
- | - Game Loop | + | |
- | - Early Update | + | |
- | - `UpdatePreloading` (Scene Loading happens here) | + | |
- | - Update | + | |
- | (The scene load pipeline | + | The scene loading queue is a pipeline, and only one AsyncOperation can progress at a time. Calling |
- | the pipeline | + | |
- | If scene unloads get flushed too, we'll need to add a bit of logic for it, in the same way LoadSceneAsync | + | |
- | does. | + | |
- | # Header | + | During the '' |
- | Notes [link](google.com) | + | |
+ | The scene loading pipeline only seems to execute a single operation, every other frame.< | ||
+ | |||
+ | * Frame N+0: Scene1 | ||
+ | * Frame N+1: --- | ||
+ | * Frame N+2: Scene 2 | ||
+ | * Frame N+3: --- | ||
+ | * Frame N+4: Scene 3 | ||
+ | |||
+ | |||
+ | ==== Initialization ==== | ||
+ | |||
+ | The Engine fully " | ||
+ | |||
+ | **All** AsyncOperations that are queued during initialization are fully loaded during initialization. For example, if '' | ||
+ | |||
+ | Scene unloads are probably flushed if they are in the pipeline, too.< | ||
+ | |||
+ | ===== Build Pipeline ===== | ||
+ | |||
+ | Scenes are built during standalone build in the following way: | ||
+ | |||
+ | - The active scenes are closed. | ||
+ | - Each Scene in the BuildSettings is opened. At this point prefabs are still prefab instances. | ||
+ | - '' | ||
+ | - Prefabs in the scene are flattened (turned into normal game objects). | ||
+ | - [[IProcessScene]] and PostProcessScene callbacks are called. | ||
+ | - The final scene file is saved into the standalone build file. | ||
+ | - Repeat for next scene. | ||
+ | |||
+ | ===== Sample Scene Load (Editor) ===== | ||
+ | |||
+ | Here is an example of a scene loading additively **in the middle** of a game, **in the editor**. Note that: | ||
+ | |||
+ | * Prefabs.MergePrefabs (turning prefabs into gameobjects) happens before any other callback. (editor only) | ||
+ | * Lightmapping is applied / loaded after Awake/ | ||
+ | * SceneManager.sceneLoaded happens after PostProcessScene. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ===== Scattered Notes ===== | ||
+ | * During a scene load (ie. Awake) the loading scene has '' | ||
+ | * During a scene unload (ie. Destroy) the unloading scene has '' | ||
+ | * '' | ||
+ | * When using '' | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== API Notes: ===== | ||
+ | === SceneManager.sceneLoaded === | ||
+ | * Called **after** the loaded Scene Awakes. | ||
+ | |||
+ | |||
+ |
scenemanager.1612742113.txt.gz · Last modified: 2025/01/15 04:35 (external edit)