Best practice to setup a scene, that relies on multiple events?

There are many ways to tackle the problem:

  • A preloading scene containing all your managers is a good and commonly used solution. One downside it has though is that if you have one, then you can only start testing your game in the Editor from that one particular scene - or figure out some kind of solution to get around that.

  • Manually place the [DefaultExecutionOrder ] attribute to scripts to tweak their initialization order.

  • Use a dependency injection framework to automatically initialize all your managers and pass references between them in optimal order that avoids execution order related issues.

  • Use scriptable object events, an event bus, static events etc. that allow subscribing to an event regardless of whether or not the instance that raises the event exists.

  • Use weak cross-scene references to assign references between managers. These could e.g. be scriptable object assets like LevelManagerReference, UIManagerReference and so on. Then when a client needs to access a member in a manager, the reference to the manager gets retrieved on-the-fly.