31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
from pathlib import Path
|
|
|
|
|
|
OUTPUT_FILE_NAME = "all-prefab-path.txt"
|
|
MODEL_RENDERER_PARTS = ("Assets", "ModelRenderer", "Art", "Models")
|
|
|
|
|
|
def find_model_renderer_root(start_path: Path) -> Path:
|
|
for path in (start_path, *start_path.parents):
|
|
if path.parts[-len(MODEL_RENDERER_PARTS):] == MODEL_RENDERER_PARTS:
|
|
return path
|
|
|
|
raise FileNotFoundError("Could not find Assets/ModelRenderer in the script path.")
|
|
|
|
|
|
def main() -> None:
|
|
script_dir = Path(__file__).resolve().parent
|
|
model_renderer_root = find_model_renderer_root(script_dir)
|
|
output_path = script_dir / OUTPUT_FILE_NAME
|
|
|
|
prefab_paths = sorted(model_renderer_root.rglob("*.prefab"))
|
|
|
|
with output_path.open("w", encoding="utf-8", newline="\n") as output_file:
|
|
for prefab_path in prefab_paths:
|
|
relative_path = prefab_path.with_suffix("").relative_to(model_renderer_root.parent)
|
|
output_file.write(str(relative_path) + "\n")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|