Unity does not provide much direction on how to transfer game state between scenes. Some community suggestions are singletons, static variables or DontDestroyOnLoad. But these have other effects that you might not want. Here, I will share a pattern inspired by functional programming I call Stateless Scenes. This pattern, inspired by asynchronous APIs, leads to a much cleaner design.
We consider a scene to be: a long running operation that, given its inputs, eventually produces an outcome. We can rephrase that as: a function that accepts a callback (a.k.a. Action) in its argument list:
To actually implement this …