检查Unity构建是否成功(UNITY C#)

时间:2018-08-28 07:52:55

标签: c# unity3d

这是我用于以编程方式进行构建的脚本

BuildPlayerOptions szBuildResult = new BuildPlayerOptions();
szBuildResult.scenes = scenes;
szBuildResult.locationPathName = m_szapkFileName;
szBuildResult.target = BuildTarget.StandaloneWindows;
szBuildResult.options = BuildOptions.None;

BuildPipeline.BuildPlayer(szBuildResult);

现在我试图做这样的事情

string result = BuildPipeline.BuildPlayer(szBuildResult);

但是它给我返回了一个错误提示

  

无法将类型UnityEditor.Build.Reporting.BuildReport转换为字符串

如何检查构建是否成功?

我正在使用Unity 2018.2

1 个答案:

答案 0 :(得分:2)

BuildPipeline.BuildPlayer将返回BuildReport对象。因此请使用BuildReport而不是string

BuildReport result = BuildPipeline.BuildPlayer(szBuildResult);