extends Control class_name ToggleSwitch enum SwitchTypes {Standard, Covered} @export var type : SwitchTypes = SwitchTypes.Standard @onready var cover = $Cover @onready var switch = $Switch @onready var mount = $Mount # Called when the node enters the scene tree for the first time. func _ready() -> void: if type != SwitchTypes.Covered: cover.hide() mount.hide() switch.position = Vector2(0,0) custom_minimum_size = switch.size if type == SwitchTypes.Covered: switch.reparent(cover) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass func _on_cover_flipped(flipped_down: bool) -> void: switch.disabled = flipped_down if flipped_down: switch.button_pressed = false switch.mouse_filter = MOUSE_FILTER_IGNORE switch.show_behind_parent = true else: switch.mouse_filter = MOUSE_FILTER_PASS switch.show_behind_parent = false