1extends Button 2 3func _ready(): 4 # This ensures that this Node won't be paused, allowing it to 5 # process even when the SceneTree is paused. Without that it would 6 # not be able to unpause the game. Note that you can set this through 7 # the inspector as well. 8 pause_mode = Node.PAUSE_MODE_PROCESS 9 10 11func _toggled(button_pressed): 12 # Pause or unpause the SceneTree based on whether the button is 13 # toggled on or off. 14 get_tree().paused = button_pressed 15 if button_pressed: 16 text = "Unpause" 17 else: 18 text = "Pause" 19