12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import argparse
- import sys
- import shutil
- from pathlib import Path
- # Add the utils directory to the Python path
- utils_path = Path(__file__).parent.parent / 'utils'
- sys.path.append(str(utils_path))
- from file_utils import find_files_by_extension
- def main():
- parser = argparse.ArgumentParser(description="Copies all shader files (.shader, .shadergraph) to the target directory.")
- parser.add_argument("--input", type=str, required=True, help="The root directory of the target Unity project.")
- parser.add_argument("--output", type=str, required=True, help="The directory where the output will be saved.")
- args = parser.parse_args()
- input_dir = Path(args.input).resolve()
- output_dir = Path(args.output).resolve()
- assets_dir = input_dir / "Assets"
- output_assets_dir = output_dir / "Assets"
- if not assets_dir.is_dir():
- return
- shader_files = find_files_by_extension(str(assets_dir), '.shader')
- shader_graph_files = find_files_by_extension(str(assets_dir), '.shadergraph')
- files_to_copy = shader_files + shader_graph_files
- if not files_to_copy:
- print("No shader files found to copy.")
- return
- print(f"\n--- Starting Shader Handling ---")
- print(f"Found {len(files_to_copy)} shader files to copy.")
- for file_path_str in files_to_copy:
- file_path = Path(file_path_str)
- relative_path = file_path.relative_to(assets_dir)
- destination_path = output_assets_dir / relative_path
-
- destination_path.parent.mkdir(parents=True, exist_ok=True)
-
- try:
- shutil.copy(file_path, destination_path)
- except IOError as e:
- print(f"Error copying {file_path} to {destination_path}: {e}", file=sys.stderr)
-
- print("Shader copying complete.")
- if __name__ == "__main__":
- main()
|