var scene_path="res://
func _ready() -> void:
ResourceLoader.load_threaded_request(scene_path)
func _process(delta: float) -> void:
ResourceLoader.load_threaded_get_status(scene_path,list)
if list[0]==1:
#作为节点
var scene=ResourceLoader.load_threaded_get(scene_path).instantiate()
#作为场景
get_tree().change_scene_to_packed(ResourceLoader.load_threaded_get(scene_path))
这是动态加载单个场景的代码,
如果用load()实现的话就会有卡顿,
我的设想就是做一个N*N的列表,N为小场景的个数,将小场景的链接关系写在列表里
玩家的所在场景也记录在变量里
在ready函数中就先加载好初始位置的场景,使用线程将邻居场景实现。
当玩家场景变化时,再使用线程将玩家的所在小场景的邻居实现,随后queue_free()现在不是邻居的小场景