Description
Changelog
Reviews (0)

Godot Scene Selector Addon

Scene selector icon (mouse on top of clapperboard)
Screenshot of scene selector addon in the Godot editor

Godot addon that adds a dropdown in the Godot editor toolbar that lets you quickly select from a list of scenes that you configure.

Adding "spawn points" lets you choose between different points in the world to teleport players to after the game loads.

The goal of this add-on is to be general purpose and easy to drop-in to any project.

Setting the project's main scene

Scene selector works by running its own scene as the main scene of your project.

This scene simply looks up the currently selected scene/spawn node and then emits the static start_scene signal.

To set this up:

  • In your project's FileSystem panel, navigate to addons/scene_selector
  • Right-click scene_selector_main.tscn
  • Select "Set as Main Scene"

Usage

UI Overview

Annotated Scene Selector UI overview

  1. Scene Selector button: This shows the currently selected scene
    • Clicking on this opens the dropdown
    • If a spawn node is selected, then a little character will be rendered to the right of this
    • Hover over this for a tooltip with the path to the scene selected, the full name of the scene, and the selected spawn node
  2. Scene: Click a scene to select it
    • The popup will close and the button will update
    • This is persisted on your machine and will stick even after restarting the editor. This is _not_ saved to the game's files at all, so each developer will need to select a scene to run.
  3. Open scene button: Clicking this will open the scene in the editor
  4. Spawn node: If a scene has spawn nodes, then it can be expanded to select a spawn node
    • If a spawn node is selected, then a little character will be rendered next to the scene selector toolbar button
  5. Edit scene list button: Click this to bring up the scene list resource for adding/removing scenes

Using the SceneSelector.start_scene signal

When starting the project with Scene Selector as the main scene, it will automatically emit a static SceneSelector.start_scene signal that you can listen to inside of a singleton (autoload).

From this, you can set up your own scene loading logic such as showing a loading screen, position the player properly, etc.

The signal includes two parameters:

  • scene: String: Location of the scene to load
    • This will be a uid:// reference and _not_ a res:// reference
  • spawn_node: NodePath: Selected spawn node inside of the given scene
    • If no spawn node is selected, this will be an empty string ""

Example autoload that listens to the signal and starts the scene:

extends Node

func _ready() -> void:
    SceneSelector.start_scene.connect(_on_start_scene)

func _on_start_scene(scene: String, spawn_node: NodePath) -> void:
    # you could also show a loading screen here!
    var packed := load(scene) as PackedScene
    var loaded_scene := packed.instantiate()

    # swap out the current scene
    get_tree().current_scene.free()
    get_tree().root.add_child(loaded_scene)
    get_tree().current_scene = loaded_scene

    # move the player to the selected spawn point
    if spawn_node:
        var spawn := loaded_scene.get_node(spawn_node)

        # move the player here, for example:
        # player.global_position = spawn.global_position

See also:

Adding scenes to select from in scene_selector_data.tres

When the addon first loads, it will create a scene_selector_data.tres resource at the root of your project.

!!! You should check this file into source control !!!

Double-click on this to open it up in the inspector, or select "Edit scene list..." from the Scene Selector popup.

Once scene_selector_data.tres is opened, you can add a new scene:

  • Open up the "Scenes" array
  • Click "+ Add Element"
  • Click ""
  • Select SceneSelectorDataItem
  • Click on the new item to expand it

From here, you can set the values for each scene you want to select from.

Screenshot of editing the scene selector resource in Godot

  • Scene Path (required): Path to the scene to load when starting the game
  • Display Name (optional): By default, the scene's file name will be used. This lets you override it.
    • For example, res://my_scene.tscn would display as my_scene
  • Display Color (optional): Used for the text color when showing the scene

The order of the scenes can be changed by dragging the elements up/down.

Inside of here, you can also change the width / height of the popup that is shown when the scene selector button is clicked. This can be useful if you have particularly long file names, otherwise they are truncated automatically. The popup will scroll vertically when the list grows long enough.

Adding spawn nodes with the scene_selector_spawn_node group

When a scene is opened in the editor, if it is in the scene list inside of scene_selector_data.tres, then Scene Selector will find all nodes that are in the scene_selector_spawn_node group and add them to the select list.

It is recommended to use Marker3D for these. It will show up visible in the editor, but not at runtime.

Add scene_selector_spawn_node as a global group
  • Go to Project -> Project Settings
  • Select the "Globals" tab
  • Select the "Groups" tab
  • Under name, put scene_selector_spawn_node
  • Under description, put Spawn locations picked up by scene selector
  • Click "+ Add"
Refreshing the spawn node list in Scene Selector

When you add a new spawn node, it may not be picked up automatically by Scene Selector.

To refresh the list, close and then re-open the scene in the editor.

What about production builds?

When making a production (non-debug) build of your game, the first entry in scene_selector_data.tres will be used, even if you've selected something different.

As such, this should be the main menu of your game or some other entry point.

Changelog for version v0.1.1

No changelog provided for this version.

Reviews

Scene Selector has no reviews yet.

Login to write a review.

Consider supporting the creators!

If you enjoyed this asset consider supporting its creator. Follow the link below.