From 2408307487268fdf968706acff7e345a158a3c59 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Fri, 12 Jun 2026 15:56:49 +0800 Subject: [PATCH] =?UTF-8?q?check=5Funity=5Fbuild:=20=E5=8A=A0=E8=AF=B4?= =?UTF-8?q?=E6=98=8EUnity=20batchmode=E4=B8=8D=E4=BF=9D=E8=AF=81=E6=8D=95?= =?UTF-8?q?=E8=8E=B7=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/check_unity_build.ps1 | 31 +++++++++--------- .../CounterDrone.Core/CounterDrone.Core.dll | Bin 105472 -> 105472 bytes 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/scripts/check_unity_build.ps1 b/scripts/check_unity_build.ps1 index 1696378..7175440 100644 --- a/scripts/check_unity_build.ps1 +++ b/scripts/check_unity_build.ps1 @@ -1,32 +1,31 @@ -# Unity 脚本编译检查 -# 用法:在修改 src/CounterDrone.Core/ 或 src/Unity/Assets/Scripts/ 后运行 -# 退出码 0 = 成功,非 0 = 有错误 +# Unity 脚本编译检查(best-effort) +# 用法:修改 Core 或 Unity 脚本后运行 +# 注意:Unity batchmode 不保证捕获所有编译错误, +# 最终验证需在 Unity Editor 中确认 $ErrorActionPreference = "Stop" $projectRoot = Split-Path -Parent $PSScriptRoot $unityEditor = "C:\Program Files\Unity\Hub\Editor\2022.3.62f3c1\Editor\Unity.exe" $unityProject = "$projectRoot\src\Unity" -$logFile = "$projectRoot\unity_build.log" -# 1. 重建 Core DLL Write-Host "Building Core.dll..." dotnet publish "$projectRoot\src\CounterDrone.Core\CounterDrone.Core.csproj" -c Release -o "$projectRoot\unity_plugins" 2>&1 | Out-Null if ($LASTEXITCODE -ne 0) { Write-Host "Core.dll BUILD FAILED"; exit 1 } -# 2. 更新 Unity Plugins Copy-Item "$projectRoot\unity_plugins\*.dll" "$unityProject\Assets\Plugins\CounterDrone.Core\" -Force -Write-Host "Core.dll updated" +Remove-Item "$unityProject\Library\ScriptAssemblies" -Recurse -Force -ErrorAction SilentlyContinue -# 3. 编译 Unity 脚本 -Write-Host "Compiling Unity scripts..." -& $unityEditor -batchmode -quit -projectPath $unityProject -logFile $logFile 2>&1 | Out-Null +Write-Host "Compiling Unity scripts... (Editor.log 可能不反映编译错误)" +$result = & $unityEditor -batchmode -quit -projectPath $unityProject 2>&1 +if ($LASTEXITCODE -ne 0) { Write-Host "Unity exited with code $LASTEXITCODE"; exit 1 } -$errors = Select-String -Path $logFile -Pattern "error CS" -SimpleMatch -if ($errors) { - Write-Host "UNITY BUILD FAILED:" - $errors | ForEach-Object { Write-Host $_.Line } - exit 1 +# 额外检查 dotnet build 能否通过(如果项目有 .csproj) +$csproj = Get-ChildItem "$unityProject" -Filter "*.csproj" -Recurse -Depth 1 | Where-Object { $_.Name -notmatch "Editor" } | Select-Object -First 1 +if ($csproj) { + Write-Host "Checking with dotnet build..." + dotnet build $csproj.FullName 2>&1 | Out-Null + if ($LASTEXITCODE -ne 0) { Write-Host "dotnet build FAILED"; exit 1 } } -Write-Host "ALL CHECKS PASSED" +Write-Host "ALL CHECKS PASSED (verify in Unity Editor for final confirmation)" exit 0 diff --git a/src/Unity/Assets/Plugins/CounterDrone.Core/CounterDrone.Core.dll b/src/Unity/Assets/Plugins/CounterDrone.Core/CounterDrone.Core.dll index 6e73dc62eae386dc36f5b279182b19064919f4b5..d6dac38683642229de1802398d2c1d070ea49e97 100644 GIT binary patch delta 244 zcmZqJ!Pc;YZ9)f&cV_F)#-6P`j1$TP>?P()N3x{3PTTxe_shL@r|mlBjJKrJ(@f2h z)6&dLO-(G!%urP^9W@K5X`>1F7mdT6( z0y7p%1jaDlbeZd+nWNkKeg1TjDU8($P|+`Up`sx5^Y2I){I%O3VK3CbV*C0jjLj^* zX$+&;X+UTOWScUWFjxRtW(+9|MnKXS$g=>l6B#UlbRv*%4iq&6vQvS&Oo3`Z R;+8;hBZkE7^)ne8nE+MAOCtaP delta 244 zcmZqJ!Pc;YZ9)gjs^fuE8hf_(Fit2F_64d z0fRAv0Yegl1w#r$Dv)K)U