Godot Version
v4.1.3.stable.official [f06b6836a]
Question
I have an issue where a control scene’s buttons are no longer clickable upon switching back to it through get_tree().change_scene_to_file()
.
When using SceneTree.change_file_to_scene
to switch control scenes (traversing through the game menus), it works as intended, but when running the game and returning to menus, the menu buttons are no longer clickable.
Here’s my provided video showcasing the issue
Menu screen script
extends Control
@onready var start_game_btn = %UIStartGameButton
@onready var level_select_btn = %UILevelSelectButton
@onready var credits_btn = %UICreditsButton
func _ready():
start_game_btn.pressed.connect(start_game)
level_select_btn.pressed.connect(enter_level_select)
credits_btn.pressed.connect(enter_credits)
func start_game():
enter_menu("res://menus/runtime/levels/level_0.tscn")
func enter_level_select():
enter_menu("res://menus/menu_level_selection.tscn")
func enter_credits():
enter_menu("res://menus/menu_credits.tscn")
func enter_menu(menu: String):
get_tree().change_scene_to_file(menu)
Game runtime’s pause menu script snippets
extends Control
@onready var ui_pause_unpause_runtime = %UIPauseUnpauseRuntime
func _ready():
ui_pause_back_button.pressed.connect(_on_quit_button_pressed)
func _on_quit_button_pressed():
get_tree().change_scene_to_file("res://menus/menu_title_screen.tscn")
After returning with change_scene_to_file("res://menus/menu_title_screen.tscn")
on the game pause menu, the title screen’s button are no longer clickable. Unlike change_scene_to_file("res://menus/menu_level_selection.tscn")
and change_scene_to_file("res://menus/menu_credits.tscn")
in the title screen that allowed clickability when returning.
How can I fix this behavior from happening? If there’s any information needed, I will gladly share.