Godot - Creating and Adding Buttons to a ButtonGroup
This GDScript code demonstrates how to create a new ButtonGroup and add buttons to it.
To create a ButtonGroup node from a script, use ButtonGroup.new()
.
To display it, you need to add it as a child using add_child()
.
# Create a ButtonGroup node
var button_group = ButtonGroup.new()
add_child(button_group)
To add a Button node to a ButtonGroup, use the following code.
# Create a Button node
var button = Button.new()
add_child(button)
button.set_text("This is a Button")
# Add the Button node to the ButtonGroup
button_group.add_child(button)
TitleGodot - Creating and Adding Buttons to a ButtonGroup
CategoryGodot
Created
Update
AuthorYousuke.U