|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
DeafSavage |
I have an InputEventMouseButton
with a if
statement in GDscript that once clicked, something shows. I want the Label text to pop up. I’m not sure if show()
is the right solution, I want to toggle the visiblity of the text as soon as a button is clicked. How do I go about this?
Both of the answers worked, thank you very much!
DeafSavage | 2020-05-07 21:56
|
|
|
 |
Reply From: |
ArthyChaux |
I would say you should connect your button to a function that shows it. So something like :
if not $Label.is_visible():
$Label.show()
You just need to change $Label by the label path, and make sure it is hidden before, so either in the editor you hide it or you do
$Label.hide()
|
|
|
 |
Reply From: |
jgodfrey |
As an example, create a new scene with the following node tree:
CanvasLayer
Button
Label
Now, wire the pressed
signal of the Button
to this script (stored on the CanvasLayer
node in this case):
extends CanvasLayer
func _on_Button_pressed():
$Label.visible = !$Label.visible
The label’s visibility will be “toggled” with each click of the button.