param( [string]$Out = "$env:TEMP\grasscutter_demo", [switch]$SkipAssets, [switch]$SkipDemo ) # Rebuilds the generated project content, builds the Windows player and runs the scripted demo off-screen # (-batchmode + BotCapture render textures: no window, no mouse capture). $ErrorActionPreference = "Stop" $p = Split-Path -Parent $PSScriptRoot $u = "C:\Program Files\Unity\Hub\Editor\6000.6.2f1\Editor\Unity.exe" # asset building renders icons, so it needs a graphics device (still -batchmode: no window) function Run-Unity($method, $log, [switch]$NoGraphics) { $gfx = @(); if ($NoGraphics) { $gfx = @("-nographics") } & $u -batchmode @gfx -projectPath $p -logFile "$p\Logs\$log" -executeMethod $method | Out-Null $code = $LASTEXITCODE $errs = Select-String -Path "$p\Logs\$log" -Pattern "error CS|Exception:" | Select-Object -First 20 if ($errs) { $errs | ForEach-Object { Write-Host $_.Line } } if ($code -ne 0) { throw "$method failed (exit $code), see Logs\$log" } } if (-not $SkipAssets) { Run-Unity "GrassCutter.EditorTools.ProjectBuilder.BatchBuildAll" "build_all.log"; Write-Host "assets OK" } Run-Unity "GrassCutter.EditorTools.ProjectBuilder.BatchBuildPlayer" "build_player.log" -NoGraphics; Write-Host "player OK" if (-not $SkipDemo) { if (Test-Path $Out) { Remove-Item $Out -Recurse -Force } $proc = Start-Process "$p\Builds\GrassCutter\GrassCutter.exe" -ArgumentList "-batchmode -autodemo `"$Out`" -logFile `"$Out.log`"" -PassThru if (-not $proc.WaitForExit(780000)) { $proc.Kill(); Write-Host "demo killed (timeout)" } Get-ChildItem $Out -ErrorAction SilentlyContinue | ForEach-Object { Write-Host $_.Name } Select-String -Path "$Out.log" -Pattern "Exception|NullReference|missing|\[Boot\]|\[Grab\]|Error" | Select-Object -First 30 | ForEach-Object { Write-Host $_.Line } }