material-maker/start.gd

32 lines
788 B
GDScript3
Raw Normal View History

extends Control
var loader
2020-02-08 09:37:46 +01:00
onready var progress_bar = $VBoxContainer/ProgressBar
func _ready():
var path : String
if Directory.new().file_exists("res://material_maker/main_window.tscn"):
path = "res://material_maker/main_window.tscn"
else:
path = "res://demo/demo.tscn"
loader = ResourceLoader.load_interactive(path)
if loader == null: # check for errors
print("error")
queue_free()
2020-02-08 09:37:46 +01:00
func _process(_delta):
var err = loader.poll()
if err == ERR_FILE_EOF:
var resource = loader.get_resource()
var scene = resource.instance()
get_node("/root").add_child(scene)
queue_free()
elif err == OK:
var progress = float(loader.get_stage()) / loader.get_stage_count()
2020-02-08 09:37:46 +01:00
progress_bar.value = 100.0*progress
else: # error during loading
print("error")
queue_free()