2024-01-23 18:48:13 +02:00
|
|
|
extends Node3D
|
|
|
|
class_name Tabs3D
|
|
|
|
|
|
|
|
signal on_select(selected: int)
|
|
|
|
|
2024-03-21 14:29:10 +02:00
|
|
|
var selected: Node3D:
|
|
|
|
set(value):
|
|
|
|
if selected == value:
|
|
|
|
return
|
|
|
|
|
|
|
|
if selected != null:
|
|
|
|
selected.active = false
|
|
|
|
|
|
|
|
selected = value
|
|
|
|
selected.active = true
|
|
|
|
on_select.emit(selected.get_index())
|
2024-01-23 18:48:13 +02:00
|
|
|
@export var initial_selected: Node3D
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
if initial_selected != null:
|
|
|
|
selected = initial_selected
|
|
|
|
|
|
|
|
for option in get_children():
|
|
|
|
if option is Button3D == false:
|
|
|
|
continue
|
|
|
|
|
2024-03-21 14:29:10 +02:00
|
|
|
option.on_button_down.connect(func():
|
|
|
|
selected=option
|
2024-01-23 18:48:13 +02:00
|
|
|
)
|
2024-03-21 14:29:10 +02:00
|
|
|
|
2024-01-23 19:02:41 +02:00
|
|
|
option.toggleable = true
|