- Edited
My menu opens fine with the below code, adds the open menu to the array, increasing it's size to 1. I do this so the close menu button will close the last menu opened first, working back. But after the first menu is opened, pressing the key (Esc) does nothing. Not even a print statement. Why is that, since the array size is no longer less than 1...?
func _input(event):
if event.is_action_pressed("ui_game_menu"):
print(open_menus)
get_open_menus()
print("size is: ", open_menus.size())
if open_menus.size() < 1:
var game_menu = load("res://UI/Game Menu.tscn").instance()
add_child(game_menu)
get_open_menus()
print("size is: ", open_menus.size())
else:
print(open_menus[-1])
open_menus[-1].queue_free()
func get_open_menus():
open_menus = []
for child in get_tree().get_nodes_in_group("menu"):
if not self.is_a_parent_of(child):
continue
open_menus.append(child)
print(open_menus)
return open_menus```