Files
godot-demo-projects/misc/multiple_windows/scenes/disable_other.gd
2025-10-08 15:00:22 -07:00

30 lines
669 B
GDScript

extends BaseButton
enum Behavior {
ENABLE_OTHERS_WHEN_ENABLED,
ENABLE_OTHERS_WHEN_DISABLED,
}
@export var behavior: Behavior = Behavior.ENABLE_OTHERS_WHEN_ENABLED
@export var others: Array[BaseButton] = []
func _ready() -> void:
var others_disabled: bool
if behavior == Behavior.ENABLE_OTHERS_WHEN_ENABLED:
others_disabled = not button_pressed
else:
others_disabled = button_pressed
for other in others:
other.disabled = others_disabled
func _toggled(toggled_on: bool) -> void:
if behavior == Behavior.ENABLE_OTHERS_WHEN_ENABLED:
for other in others:
other.disabled = not toggled_on
else:
for other in others:
other.disabled = toggled_on