blob: 35428ea392ff6f149b2e56091827bb77d6a06ffc (
plain) (
blame)
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
29
|
extends Node
var source_path
func _init(path):
source_path = path
func load_script(path):
return ResourceLoader.load("%s/%s" % [source_path, path])
func read_path(path):
return FileAccess.get_file_as_bytes("%s/%s" % [source_path, path])
func load_script_as_scene(path, scene_name):
var script = load_script(path)
var instance = script.new()
instance.name = scene_name
get_tree().unload_current_scene()
_load_scene.call_deferred(instance)
func _load_scene(instance):
get_tree().get_root().add_child(instance)
get_tree().current_scene = instance
|