Skip to content
Manolo Cantón edited this page Jul 5, 2024 · 51 revisions

Welcome to the godot-scene-manager wiki!

Introduction

This repository stores a Godot plugin which adds extra options to adds extra options to the limited SceneTree methods for changing scenes. The main feature is to set properties for the next scene from the previous scene. To be able to use this functionality, there is the SceneManager autoload with some methods.

SceneManager.change_scene_to_file("my_scene.tscn", {
    my_next_scene_property = "a value",
})

The previous code loads the scene and sets the property my_next_scene_property with the value "a value". In the same way, you can offer a PackedScene with the following alternative code:

SceneManager.change_scene_to_packed(my_packed_scene, {
    my_next_scene_property = "a value",
})

If you need to reload a scene, you can use:

SceneManager.reload_current_scene({
    my_current_scene_property = "a value",
})

Note: I'll try to keep method names like SceneTree methods. If the names change in future Godot releases, I also change them.

Applications

When is this plugin useful? Maybe I can think about more things later, for now I have the following in mind:

  • You have a map where your player moves and you did other amazing scene for your battle. Maybe your map scene has the data to load the battle scene, therefore you pass the data as an initial variable in the battle scene. This way, in your root node script, you handle that data in your _ready method.

  • Loading big scenes. When you change the scene using the path, the PackedScene can be loaded in the background adding a min_duration value greater than 0.0.

Clone this wiki locally