Skip to main content
SceneManager is an autoload singleton that wraps Godot’s built-in change_scene_to_packed behind a name-based API. Instead of scattering preload calls and packed-scene references throughout your scripts, you call a single method with a string name and SceneManager handles the rest.
SceneManager is registered as an autoload in the project settings, which means it is available from any script in the game without importing or obtaining a node reference.

Class overview

scene_manager.gd
# extends Node (Autoload singleton)
At startup, SceneManager loads a Scenes resource (scenes.tres) from uid://bn7v8txng2pda. This resource maps human-readable string names to PackedScene instances and is viewable and editable in the Godot Inspector.

Initialization

func _ready():
    _scenes.expected_type = TYPE_OBJECT
    _scenes.check_item_types()
_ready() validates that every entry in the Scenes resource is a proper Object (i.e., a loaded PackedScene). If any entry has the wrong type, check_item_types() logs an error at startup rather than failing silently at the moment of a scene transition.
The validation in _ready() surfaces configuration mistakes early. If you add a new scene to scenes.tres but accidentally leave an entry blank or assign the wrong asset type, you will see the error in the output panel when the game boots — not when a player triggers that transition for the first time.

API reference

change_to_scene(scene_name: String) -> void

Transitions to the scene identified by scene_name, replacing the current scene tree root.
scene_name
String
required
The name of the scene as registered in scenes.tres. This is a case-sensitive string key. If the key does not exist, _scenes.get_item() will raise an error.
func change_to_scene(scene_name: String) -> void:
    get_tree().change_scene_to_packed(_scenes.get_item(scene_name))

Usage examples

The Scenes resource

All scene names are defined in scenes.tres. You can view and edit this file in the Godot Inspector by opening the resource in the FileSystem dock.
Scene names in scenes.tres are the only source of truth for valid change_to_scene arguments. There is no code-level enum or constant listing them — use the Inspector to see which names are registered.

Adding a new scene

1

Create and save your scene

Build your new scene in Godot and save it as a .tscn file (e.g., res://scenes/credits.tscn).
2

Open scenes.tres in the Inspector

In the FileSystem dock, locate scenes.tres and open it. The resource will display its dictionary of name → PackedScene entries.
3

Add a new entry

Add a new key-value pair: set the key to a descriptive string (e.g., "credits") and the value to your new .tscn file.
4

Verify at startup

Run the project. If check_item_types() in _ready() logs no errors, your scene is correctly registered and ready to use.
5

Call change_to_scene

Use your new key anywhere in the project:
SceneManager.change_to_scene("credits")

Autoloads

Overview of all autoload singletons and when they are initialized.

FlagsManager

Use flags to decide which scene to load at runtime.

MusicManager

Switch background music when you transition between scenes.

Architecture overview

How autoloads, scene nodes, and the state machine fit together.

Build docs developers (and LLMs) love