powershell - Unity.exe 命令行构建需要 10 分钟,但编辑器需要不到一分钟
问题描述
有时我在 Unity 编辑器中构建我的项目,只需要不到一分钟的时间。
但我也喜欢做一个命令行构建,我注意到这需要十分钟。有什么办法可以解决这个问题,让它构建得更快吗?这是我的命令行的样子——我使用 powershell 以便在构建实际完成之前批处理文件不会继续。也许它与“-Wait”有关,但如果我不把它放在命令行中,在构建完成之前继续。
powershell -Command "Start-Process -FilePath C:\Users\me\source\Unity\Editors\2019.3.5f1\Editor\Unity.exe -ArgumentList '-batchmode -projectpath C:\Users\me\source\repos\MyProject -buildWindows64Player C:\mybuild\MyProject.exe -quit' -Wait" time /T
解决方案
我最终通过在构建时密切观察过程来弄清楚这一点。事实证明,如果您有脚本,构建过程也会导致 VBCSCompiler.exe 运行。如果这是由 Unity 启动的,那么它将是启动的进程树的一部分。它会保持开放十分钟,以防有更多工作要做。请参阅此处了解更多信息。
所以为了解决这个问题,我改变了我的代码:
powershell -Command "$unity = Start-Process -FilePath C:\Users\me\source\Unity\Editors\2019.3.5f1\Editor\Unity.exe -ArgumentList '-batchmode -projectpath C:\Users\me\source\repos\MyProject -buildWindows64Player C:\mybuild\MyProject.exe -quit' -PassThru; Start-Sleep -Seconds 3.0; Write-Host -NoNewLine 'Building...'; while ((Get-WmiObject -Class Win32_Process | Where-Object {$_.ParentProcessID -eq $unity.Id -and $_.Name -ne 'VBCSCompiler.exe'}).count -gt 0) { Start-Sleep -Seconds 1.0; Write-Host -NoNewLine '.' }; if (!$unity.HasExited) { Wait-Process -Id $unity.Id }; exit $unity.ExitCode"
推荐阅读
- c# - unity 实例化和设置位置
- data-binding - 剑道:将远程日期源绑定到表单
- javascript - 如何仅获取更改的输入字段
- ruby-on-rails - 单击提交按钮后没有任何反应(Ruby on Rails)
- c - 打印 UTF-16 字符串
- mysql - 如何正确格式化我的 UPDATE 语句?获取非唯一表/别名错误
- kubernetes - Kubernetes:为自定义资源创建事件
- gravity-forms-plugin - GravityForms GFAPI::get_entries 中的 ANY/ALL (AND/OR) 组合?
- c# - 如何在方法中实例化类 T
- recursion - Thinkscript:递归计数器