Modals - m-canton/godot-scene-manager GitHub Wiki
Backdrop
SceneManagerBackdrop
is a custom Control class to add a child control to show and hide like a modal. If the first child is not your modal node, it won't work because get_child(0)
is used to get the node.
You should add backdrop with the screen size. When you click on backdrop, you close the modal. You can change this behavior by disabling close_modal_on_clicked
and connecting close_modal_requested
to a method.
Your scene node tree should be similar to the following:
Control (control.gd attached)
|- MainControl (Control type)
|- SceneManagerBackdrop (Anchor Preset: Full Rect)
|- Modal (Control type)
#control.gd
extends Control
@onready var open_button: Button = $MainControl/OpenButton
@onready var backdrop: SceneManagerBackdrop = $SceneManagerBackdrop
func _ready() -> void:
open_button.pressed.connect(_on_open_modal)
func _on_open_modal() -> void:
backdrop.open_modal().finished.connect(_on_modal_opened)
func _on_modal_opened() -> void:
print("Modal open!")
Check res://addons/scene_manager/test/modals/modals.tscn
to see an example.
Animation
Backdrop starts a tween to change opacity and position. Check Animation property group in the inspector to see all the options.