- Automatically build dependencies index everytime a scene is saved, and pack all scenes' dependencies configuration into one single asset.
- The saved dependencies is used when
SceneDependencyRuntime.LoadSceneAsyncis called, all the dependencies will be prepared before the subject scene is loaded. - Should be highly compatible to all kinds of project setups.
- Supports both Unity's built-in system (SceneManager)
and Addressables(Not implemented as for now, it's really hard to design a structure and interface that can works for both systems due to the huge difference between Addressable and SceneManager).
Depedendency diagram:
A
├──A.Dep1
│ ├── A.Dep1.Dep
│ └──A.Dep1+2.Dep (Depended by both A.Dep1 and A.Dep2)
└──A.Dep2
├──A.Dep2.Dep
└──A.Dep1+2.Dep (Depended by both A.Dep1 and A.Dep2)
We execute SceneDependencyRuntime.LoadSceneAsync, targeting scene A.
- After importing this library, it hooks into scene saving whenever Unity recompiles.
- When a scene is saved, it checks if there's a
SceneDependencyProxyand does the proxy pointing to a validSceneDependencyscriptable object. - If so, it will make sure this scene is indexed and saved into the
SceneDependencyIndexscriptable object, the object is project level Singleton. - As long as the
SceneDependencyIndexasset is included in build/addressables, allSceneDependencyshould be included as well. - When
SceneDependencyRuntime.LoadSceneAsyncis called, it lookup all the scenes that needs to be loaded (includnig deps of deps of deps... etc.) then load all of them before loading the requested scene. - So it's very easy, create
SceneDependencyscriptable object for every scene that you want to specify its dependencies and add aSceneDependencyProxywith theSceneDependencyreferenced. Save. Done.
