/// <summary> Push a new scene onto the stack. </summary> public static void Push(PrimeScene scene, bool hideSceneBelow = true) { if (scene == null) { return; } scene.IsHidingSceneBelow = hideSceneBelow; SuspendTopScene(hideSceneBelow); Stack.Add(scene); if (scene.AttachToViewport) { CanvasLayer canvasLayer = new CanvasLayer(); canvasLayer.Name = $"{scene.Name}"; canvasLayer.AddChild(scene); StackRoot.AddChild(canvasLayer); } else { StackRoot.AddChild(scene); } Tree.SetInputAsHandled(); scene.OnPushed(); scene.OnCurrent(); }
/// <summary> Clear all scenes off the stack (if any) and push a new scene. </summary> public static void Set(PrimeScene scene) { Prime.Unpause(); Tree.SetInputAsHandled(); ClearAll(); Push(scene, true); }
private static void QueueFreeScene(PrimeScene scene) { if (scene.AttachToViewport) { scene.GetParent().QueueFree(); } else { scene.QueueFree(); } }
/// <summary> Called on the topmost PrimeScene when another PrimeScene is pushed on top of it. </summary> private static void SuspendTopScene(bool hide) { if (Stack.Count > 0) { PrimeScene scene = TopScene; scene.Visible = !hide; scene.SetProcess(false); scene.SetPhysicsProcess(false); scene.SetProcessInput(false); scene.OnSuspended(); } }
/// <summary> Push a scene that's already in the scenetree onto the stack. This should only be required when launching the game with F6 for debugging. </summary> public static void PushForF6Launch(PrimeScene scene) { Stack.Add(scene); scene.OnPushed(); scene.OnCurrent(); }