Scene singleton error with DontDestroyOnLoad

|singular~niche| 4 years ago updated by Lazlo Bonin (Lead Developer) 4 years ago 7

see pics – i clearly have a scene variable called "sceneToLoad" yet it's not being found, and i'm getting error messages about a Bolt.SceneVariables singleton.

thanks for any help.


Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Satisfaction mark by |singular~niche| 4 years ago

using Unity 2017.3.0f3 on MacOS 10.13.3

More info:

i created a new 3D game, added an empty game object and placed a Bolt flow machine on that game object. also of course added a scene variable called "sceneToLoad" – an int with an initial value of 0.

this works fine:

this doesn't work:

hope this helps.

found a workaround using the fallback value. :)

Fixed in Alpha

Interesting case :) This is actually partly a bug, partly not a bug.

The More than one singleton... error is a bug and will be fixed in v.1.2.4 alpha 2.

The fact that your variable can no longer be found isn't a bug, however. That's because behind the scenes, when you call DontDestroyOnLoad, Unity moves the target object to a temporary scene called DontDestroyOnLoad:

Then, when Bolt tries to get the scene variable for your game object, it will notice there are no scene variables in the DontDestroyOnLoad scene and create an empty set of scene variables (the last object in the previous screenshot). However, because your sceneToLoad variable was declared in your Main scene, it is no longer accessible to this object.

The correct workaround would be to use an object or graph variable in that case. These will properly get transfered even after DontDestroyOnLoad.

that explanation makes a lot of sense, Lazlo. very helpful. thanks!


just tested with 1.2.4 beta. no more scene singleton error messages, and the graph works as long as the variable is in object or graph, not scene.