diff --git a/AGENTS.md b/AGENTS.md index fdf68a0..48b1284 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -66,6 +66,16 @@ Strong success criteria let you loop independently. Weak criteria ("make it work - Example: `pwsh -Command "rg -n 'class' src/"` - Example: `pwsh -Command "./build.bat"` +## 6. Verify Unity Scripts After Changes + +**After modifying files under `src/Unity/Assets/Scripts/`, verify compilation:** + +```bash +pwsh scripts/check_unity_build.ps1 +``` + +This runs Unity in batch mode and exits 0 if compilation succeeds, non-zero if errors. + --- **These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes. diff --git a/scripts/check_unity_build.ps1 b/scripts/check_unity_build.ps1 new file mode 100644 index 0000000..e30dc40 --- /dev/null +++ b/scripts/check_unity_build.ps1 @@ -0,0 +1,20 @@ +# Unity 脚本编译检查 +# 用法:在修改 src/Unity/Assets/Scripts/ 后运行此脚本 +# 退出码 0 = 编译成功,非 0 = 有错误 + +$unityEditor = "C:\Program Files\Unity\Hub\Editor\2022.3.62f3c1\Editor\Unity.exe" +$projectPath = "C:\Users\Tellme\apps\CounterDroneBackend\src\Unity" +$logFile = "C:\Users\Tellme\apps\CounterDroneBackend\unity_build.log" + +Write-Host "Compiling Unity scripts..." +& $unityEditor -batchmode -quit -projectPath $projectPath -executeMethod CompileCheck -logFile $logFile 2>&1 | Out-Null + +$errors = Select-String -Path $logFile -Pattern "error CS" -SimpleMatch +if ($errors) { + Write-Host "BUILD FAILED:" + $errors | ForEach-Object { Write-Host $_.Line } + exit 1 +} else { + Write-Host "BUILD SUCCESS" + exit 0 +}