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
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
_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.
API reference
change_to_scene(scene_name: String) -> void
Transitions to the scene identified by scene_name, replacing the current scene tree root.
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.Usage examples
The Scenes resource
All scene names are defined inscenes.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
Create and save your scene
Build your new scene in Godot and save it as a
.tscn file (e.g., res://scenes/credits.tscn).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.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.Verify at startup
Run the project. If
check_item_types() in _ready() logs no errors, your scene is correctly registered and ready to use.Related pages
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.