12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 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 C# scripts (.cs) 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
- cs_files = find_files_by_extension(str(assets_dir), '.cs')
- if not cs_files:
- print("No C# scripts found to copy.")
- return
- print(f"\n--- Starting Script Handling ---")
- print(f"Found {len(cs_files)} C# script files to copy.")
- for script_path_str in cs_files:
- script_path = Path(script_path_str)
- relative_path = script_path.relative_to(assets_dir)
- destination_path = output_assets_dir / relative_path
-
- destination_path.parent.mkdir(parents=True, exist_ok=True)
-
- try:
- shutil.copy(script_path, destination_path)
- except IOError as e:
- print(f"Error copying {script_path} to {destination_path}: {e}", file=sys.stderr)
-
- print("Script copying complete.")
- if __name__ == "__main__":
- main()
|