can quit menus using B button
This commit is contained in:
@@ -7,15 +7,18 @@ extends Node
|
||||
@export var player : CharacterBody3D
|
||||
|
||||
@export_group("Inputs")
|
||||
@export var base_mode:GUIDEMappingContext
|
||||
@export var pause:GUIDEAction
|
||||
|
||||
var menu_already_open = false
|
||||
|
||||
func _ready() -> void:
|
||||
# GUIDE.enable_mapping_context(base_mode)
|
||||
|
||||
pause.triggered.connect(on_input_pause)
|
||||
|
||||
func on_input_pause():
|
||||
if menu_already_open:
|
||||
return
|
||||
|
||||
menu_already_open = true
|
||||
if not focused_viewport:
|
||||
focused_viewport = get_viewport()
|
||||
var _initial_focus_control = focused_viewport.gui_get_focus_owner()
|
||||
@@ -25,9 +28,6 @@ func on_input_pause():
|
||||
|
||||
get_tree().current_scene.call_deferred("add_child", current_menu)
|
||||
await current_menu.tree_exited
|
||||
menu_already_open = false
|
||||
if is_inside_tree() and _initial_focus_control:
|
||||
_initial_focus_control.grab_focus()
|
||||
|
||||
func _unhandled_input(event : InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user