This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hello! Is there a way that i can make a button, after being press, display two more buttons? Without scene change

Godot version 3.2.1
in Engine by (30 points)

2 Answers

+2 votes
Best answer

In Button > Signals > BaseButton > pressed() creates a function (put it in the main scene script) that is run when the intial button is pressed:

func _on_Button_pressed():


You then have a couple of ways depending on what you want to happen.

First: if already you have the next two buttons already created in your scene (but hidden), then use .show() on both your other buttons, maybe like this:

func _on_Button_pressed():
    $Button2.show()
    $Button3.show()


Second option: you would like new buttons (created in the script):

var button_counter = 0

func _on_Button_pressed():
    for i in 2:
        button_counter += 1
        var new_button = Button.new()
        new_button.set_name("Button"+str(button_counter)) 
        add_child(new_button)

After doing this you would then need to define every aspect of each button in the script, like its text, size, style, font, options, etx, for both buttons (this isn't shown).

Hope it helps!

by (1,016 points)
selected by

Thank you! It was way more simples than i was trying to make, haha. Thank you again

+1 vote

Hi!
Yuminous has already provided you a great answer but you can also make these more appealing. Here's a great tutorial by KidsCanCode
https://kidscancode.org/godot_recipes/ui/radial_menu/

It's somewhat complicated but still it will give you some lessons and you will learn many more great things.

by (942 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.