This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Scenes/Global/SceneManager.gd

30 lines
754 B
GDScript

extends Node
var queue = null
var target_scene = null
var loading_text = null
var loader = preload("res://Scenes/Loader.tscn")
func enter_loader():
get_tree().change_scene_to(loader)
func load_scene_with_args(scene_path: String, _args: Array):
queue = ResourceQueue.new()
queue.start()
target_scene = scene_path
queue.queue_resource(scene_path)
func _physics_process(delta):
if queue != null and target_scene != null:
if queue.is_ready(target_scene):
get_tree().change_scene_to(queue.get_resource(target_scene))
queue = null
target_scene = null
func get_progress():
if loading_text != null:
return loading_text
if queue != null and target_scene != null:
return "Loading scene (" + str(queue.get_progress(target_scene)) + ")"