From 19dec8e30b22ebe3229e4997024ff914729601e9 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Fri, 12 Jun 2026 14:47:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0check=5Funity=5Fbuild.ps1=20+?= =?UTF-8?q?=20AGENTS.md=E8=A7=84=E5=88=99:=20=E6=94=B9Unity=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=90=8E=E7=BC=96=E8=AF=91=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 10 ++++++++++ scripts/check_unity_build.ps1 | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 scripts/check_unity_build.ps1 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 +}