Files

31 lines
840 B
GDScript
Raw Permalink Normal View History

@tool
extends SceneTree
# Load and re-save every .tscn so embedded sub-resources (inline ArrayMesh,
# etc.) are rewritten in the current Godot 4 format.
func _init() -> void:
for path in _find("res://scenes", ".tscn"):
var res = ResourceLoader.load(path, "", ResourceLoader.CACHE_MODE_IGNORE)
if res is PackedScene:
if ResourceSaver.save(res, path) == OK:
print("RESAVED ", path)
quit()
func _find(dir_path: String, ext: String) -> Array:
var result := []
var dir = DirAccess.open(dir_path)
if dir == null:
return result
dir.list_dir_begin()
var name = dir.get_next()
while name != "":
if name != "." and name != "..":
var sub = dir_path + "/" + name
if dir.current_is_dir():
result.append_array(_find(sub, ext))
elif name.ends_with(ext):
result.append(sub)
name = dir.get_next()
return result