I'm making some kind of dependencies solving script. To work this script, it must be run before all other MonoBehaviour scripts.
So I made the script something like this:
public class DependencyController {
private static Dictionary<string, bool> m_DependencyTable = new Dictionary<string, bool>();
static DependencyController() {
SceneManager.sceneUnloaded += ResetDependencyData;
}
... some other stuffs ...
}
I'm using dictionary to compare which dependency script(s) loaded. To can use every script's Awake/Start, I declared as static and instantiated right after.
The system actually work pretty good, all scripts can access DependencyController in Awake/Start without any problem, but have some questions remains:
- Is static m_DependencyTable is always created before scene loaded?
- Is static DependencyController constructor always called after SceneManager is loaded? As you can see, I attached EventListener in SceneManager.sceneUnloaded so that I can clear the dependency table before scene loads.
Any advice will very appreciate it.