42 lines
964 B
GDScript
42 lines
964 B
GDScript
extends PanelContainer
|
|
|
|
var shapeButtonScene = preload("res://UI/SelectableShape/ShapeButton.tscn")
|
|
|
|
var shapes = [
|
|
{
|
|
"object": preload("res://models/horse.glb"),
|
|
"name": "horse",
|
|
"scene": preload("res://objects/horse.tscn")
|
|
},
|
|
{
|
|
"object": preload("res://models/shark.glb"),
|
|
"name": "shark",
|
|
"scene": preload("res://objects/shark.tscn")
|
|
},
|
|
]
|
|
|
|
var offset = Vector3(0, 10000, 10000)
|
|
|
|
func _ready() -> void:
|
|
setup_buttons()
|
|
|
|
func close():
|
|
visible = false
|
|
|
|
func button_clicked(index):
|
|
GlobalVariables.player.change_object(shapes[index].scene.instantiate())
|
|
close()
|
|
|
|
func setup_buttons():
|
|
var index = 0
|
|
for shape in shapes:
|
|
var newButton = shapeButtonScene.instantiate()
|
|
var buttonObject = shape.object.instantiate()
|
|
%ShapeButtons.add_child(newButton)
|
|
newButton.set_location_offset(offset)
|
|
offset += Vector3(0, 10000, 10000)
|
|
newButton.change_object(buttonObject)
|
|
|
|
newButton.pressed.connect(button_clicked.bind(index))
|
|
index += 1
|