Skip to content

Singleton (Autoload) C# ButtonPressed Code does not work #9526

Open
@rzt3

Description

@rzt3

Your Godot version:
4.2.2

Issue description:
The code below doesn't do anything.

// Add to 'Scene1.cs'.

private void OnButtonPressed()
{
    var global = GetNode<Global>("/root/Global");
    global.GotoScene("res://Scene2.tscn");
}
// Add to 'Scene2.cs'.

private void OnButtonPressed()
{
    var global = GetNode<Global>("/root/Global");
    global.GotoScene("res://Scene1.tscn");
}

Scene2.tscn and Scene1.tscn don't exist in the template provided.
This also isn't how Godot's signals work in C#. (Refer to https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_signals.html.)

Also, the user needs to create the C# scripts by themselves. (The C# files don't exist in the template)

URL to the documentation page:
https://docs.godotengine.org/en/latest/tutorials/scripting/singletons_autoload.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions