添加check_unity_build.ps1 + AGENTS.md规则: 改Unity脚本后编译检查
This commit is contained in:
parent
f2204bf3b4
commit
19dec8e30b
10
AGENTS.md
10
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.
|
||||
|
||||
20
scripts/check_unity_build.ps1
Normal file
20
scripts/check_unity_build.ps1
Normal file
@ -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
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user