diff options
author | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-15 16:29:02 +0100 |
---|---|---|
committer | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-15 16:29:02 +0100 |
commit | c9c5b5d7c2a238310ce7bde336f76d2d1b6f9f29 (patch) | |
tree | c6e935fea995752a0b307e56892e8422fb734c0e /scripts/load_shapes.gd | |
parent | 98f356e68b759bf84300290315d4ada09c41f79b (diff) |
moved shapes to loading area & fixed asset paths
Diffstat (limited to 'scripts/load_shapes.gd')
-rw-r--r-- | scripts/load_shapes.gd | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/load_shapes.gd b/scripts/load_shapes.gd new file mode 100644 index 0000000..f3de4ae --- /dev/null +++ b/scripts/load_shapes.gd @@ -0,0 +1,27 @@ +extends Node + +var loaded = false +var saveload : Node +var models : Dictionary + +func get_saveload(): + if saveload == null: saveload = get_tree().root.get_child(0).get_node("saveload") + +func _ready(): + get_saveload() + load_models() + emit_signal("done_loading") + loaded = true + +func load_models(): + models = {} + var dir = Directory.new() + dir.open("res://assets/models/shapes") + dir.list_dir_begin(true) + var shape = dir.get_next() + while shape != "": + if (shape.ends_with(".glb")): + var model = load("res://assets/models/shapes/" + shape) + var sname = shape.substr(0, shape.length()-4) + models[sname] = model + shape = dir.get_next() |