浏览代码

Give option for using current scene if build settings empty

/generic-asset-sources
Mohsen Kamalzadeh 3 年前
当前提交
4f46415f
共有 1 个文件被更改,包括 30 次插入6 次删除
  1. 36
      com.unity.perception/Editor/Randomization/Editors/RunInUnitySimulationWindow.cs

36
com.unity.perception/Editor/Randomization/Editors/RunInUnitySimulationWindow.cs


switch (buildIdKind)
{
case BuildIdKind.BuildPlayer:
CreateLinuxBuildAndZip();
buildId = await UploadBuild(cancellationTokenSource, token);
if (CreateLinuxBuildAndZip())
{
buildId = await UploadBuild(cancellationTokenSource, token);
}
break;
case BuildIdKind.ExistingBuildZip:
m_BuildZipPath = m_BuildPathField.value;

}
}
void CreateLinuxBuildAndZip()
bool CreateLinuxBuildAndZip()
var projectBuildDirectory = $"{m_BuildDirectory}/{m_RunParameters.runName}";
if (!Directory.Exists(projectBuildDirectory))
Directory.CreateDirectory(projectBuildDirectory);
List<string> scenes = new List<string>();
foreach(var scene in EditorBuildSettings.scenes)
{

if (scenes.Count == 0)
{
if (EditorUtility.DisplayDialog("No Scenes Found", "Could not find any enabled Scenes in build settings. Open File -> Build Settings and add all your required Scenes.", "Use Currently Open Scene", "Cancel Build"))
{
var currentOpenScenePath = SceneManager.GetSceneAt(0).path;
if (string.IsNullOrEmpty(currentOpenScenePath))
{
EditorUtility.DisplayDialog("Build Failed", "Could not find an active Scene.", "OK");
throw new Exception($"Could not find an active Scene.");
}
scenes.Add(currentOpenScenePath);
}
else
{
return false;
}
}
var projectBuildDirectory = $"{m_BuildDirectory}/{m_RunParameters.runName}";
if (!Directory.Exists(projectBuildDirectory))
Directory.CreateDirectory(projectBuildDirectory);
var buildPlayerOptions = new BuildPlayerOptions
{
scenes = scenes.ToArray(),

EditorUtility.DisplayProgressBar("Unity Simulation Run", "Zipping Linux build...", 0f);
Zip.DirectoryContents(projectBuildDirectory, m_RunParameters.runName);
m_BuildZipPath = projectBuildDirectory + ".zip";
return true;
}
List<AppParam> UploadAppParam()

正在加载...
取消
保存