xiandie/util/resave_all.gd
2025-01-17 18:54:46 +08:00

27 lines
676 B
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@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))