xiandie/util/resave_all.gd

27 lines
676 B
GDScript3
Raw Normal View History

2025-01-17 10:45:40 +00:00
@tool
extends EditorScript
var files: Array[String]
# https://github.com/godotengine/godot/pull/67128
# It will open and re-save all text resource files, to make sure they are up to date.
# It fixes formatting, uids, old classes etc.
# 使用方式Editor -> File -> Run
func _run() -> void:
files = []
add_files("res://")
for file in files:
print(file)
var res = load(file)
ResourceSaver.save(res)
func add_files(dir: String):
for file in DirAccess.get_files_at(dir):
if file.get_extension() == "tscn" or file.get_extension() == "tres":
files.append(dir.path_join(file))
for dr in DirAccess.get_directories_at(dir):
add_files(dir.path_join(dr))