I’ve noticed another race condition, this time in our
Fader.cs. In particular, a null reference in
Fader.FadeOutImmediate, invoked by
SavingWrapper.LoadLastScene. This became a persistent issue for me when I added a few enemies to the Sandbox 2 scene, went through the portal from the main scene, and then quit. Playing the game from this save state would cause the exception and mis-load the scene, reverting to the original scene instead.
The fix, I think, is to change
Fader.cs so that the
canvasGroup reference is properly obtained before
FadeOutImmediate is invoked by
SavingWrapper (which after this lecture now happens even earlier).