-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloading_screen.gd
More file actions
28 lines (24 loc) · 813 Bytes
/
loading_screen.gd
File metadata and controls
28 lines (24 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
extends Control
var progress_arr := []
var target_scene_path := "res://Game.tscn"
var is_loading := true
func _ready():
ResourceLoader.load_threaded_request(target_scene_path)
set_process(true)
func _process(_delta):
if not is_loading:
return
var status = ResourceLoader.load_threaded_get_status(target_scene_path, progress_arr)
$Label.text = "Generating World ..."
if status == ResourceLoader.THREAD_LOAD_LOADED:
var scene_res = ResourceLoader.load_threaded_get(target_scene_path)
if scene_res:
get_tree().change_scene_to_packed(scene_res)
else:
push_error("Failed to get loaded scene resource")
is_loading = false
set_process(false)
elif status == ResourceLoader.THREAD_LOAD_FAILED:
push_error("Loading failed for " + target_scene_path)
is_loading = false
set_process(false)