How to change singleton during runtime?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TitanicJoe

Is it possible to change singleton during runtime via code? Or set singleton during runtime?
For example. I have StartMenu scene (My tree look like: [root].[StartMenu]). After pressing start button I want to change scene and use some scripts like they were autoloaded (My new tree: [root].[AutoloadedScript_1,AutoloadedScript_2,MainScene]).

I ask, because my scripts, which I want to be autoloaded, have some referances to nodes from MainScene node. And when they are loaded from the beginning, there are ofc errors because engine cant find these nodes. Now I know, I shouldnt design Singletons in this way. Just asking if there is a solution or should I redesign all code.

:bust_in_silhouette: Reply From: klaas

i would make one master-singleton and in this master-script instanctiate your current scene script

Master.currentScene = StartMenu

when button is pressed

Master.currentScene = AutoloadedScript1

then you can allways access your current scene with