public static void LaunchOnTargets(BuildTargetGroup targetGroup, BuildTarget buildTarget, BuildReport buildReport, List <DeploymentTargetId> launchTargets) { try { if (buildReport == null || !DeploymentTargetManager.IsExtensionSupported(targetGroup, buildReport.summary.platform)) { throw new NotSupportedException(); } ProgressHandler handler = new ProgressHandler("Deploying Player", delegate(string title, string message, float globalProgress) { if (EditorUtility.DisplayCancelableProgressBar(title, message, globalProgress)) { throw new DeploymentOperationAbortedException(); } }, 0.1f, 1f); ProgressTaskManager taskManager = new ProgressTaskManager(handler); taskManager.AddTask(delegate { int num = 0; List <DeploymentOperationFailedException> list = new List <DeploymentOperationFailedException>(); foreach (DeploymentTargetId current in launchTargets) { try { DeploymentTargetManager.LaunchBuildOnTarget(targetGroup, buildReport, current, taskManager.SpawnProgressHandlerFromCurrentTask()); num++; } catch (DeploymentOperationFailedException item) { list.Add(item); } } foreach (DeploymentOperationFailedException current2 in list) { UnityEngine.Debug.LogException(current2); } if (num == 0) { throw new PostprocessBuildPlayer.NoTargetsFoundException("Could not launch build"); } }); taskManager.Run(); } catch (DeploymentOperationFailedException ex) { UnityEngine.Debug.LogException(ex); EditorUtility.DisplayDialog(ex.title, ex.Message, "Ok"); } catch (DeploymentOperationAbortedException) { Console.WriteLine("Deployment aborted"); } catch (PostprocessBuildPlayer.NoTargetsFoundException) { throw new UnityException(string.Format("Could not find any valid targets to launch on for {0}", buildTarget)); } }
static public void LaunchOnTargets(BuildTargetGroup targetGroup, BuildTarget buildTarget, Build.Reporting.BuildReport buildReport, List <DeploymentTargetId> launchTargets) { try { // Early out so as not to show/update progressbars unnecessarily if (buildReport == null || !DeploymentTargetManager.IsExtensionSupported(targetGroup, buildReport.summary.platform)) { throw new System.NotSupportedException(); } ProgressHandler progressHandler = new ProgressHandler("Deploying Player", delegate(string title, string message, float globalProgress) { if (EditorUtility.DisplayCancelableProgressBar(title, message, globalProgress)) { throw new DeploymentOperationAbortedException(); } }, 0.1f); // BuildPlayer.cpp starts off at 0.1f for some reason var taskManager = new ProgressTaskManager(progressHandler); // Launch on all selected targets taskManager.AddTask(() => { int successfulLaunches = 0; var exceptions = new List <DeploymentOperationFailedException>(); foreach (var target in launchTargets) { try { DeploymentTargetManager.LaunchBuildOnTarget(targetGroup, buildReport, target, taskManager.SpawnProgressHandlerFromCurrentTask()); successfulLaunches++; } catch (DeploymentOperationFailedException e) { exceptions.Add(e); } } foreach (var e in exceptions) { UnityEngine.Debug.LogException(e); } if (successfulLaunches == 0) { // TODO: Maybe more specifically no compatible targets? throw new NoTargetsFoundException("Could not launch build"); } }); taskManager.Run(); } catch (DeploymentOperationFailedException e) { UnityEngine.Debug.LogException(e); EditorUtility.DisplayDialog(e.title, e.Message, "Ok"); } catch (DeploymentOperationAbortedException) { System.Console.WriteLine("Deployment aborted"); } catch (NoTargetsFoundException) { throw new UnityException(string.Format("Could not find any valid targets to launch on for {0}", buildTarget)); } }
public static void Launch(BuildTargetGroup targetGroup, BuildTarget buildTarget, string path, string productName, BuildOptions options, BuildReport buildReport) { try { if (buildReport == null) { throw new NotSupportedException(); } ProgressHandler handler = new ProgressHandler("Deploying Player", delegate(string title, string message, float globalProgress) { if (EditorUtility.DisplayCancelableProgressBar(title, message, globalProgress)) { throw new OperationAbortedException(); } }, 0.1f, 1f); ProgressTaskManager taskManager = new ProgressTaskManager(handler); List <DeploymentTargetId> validTargetIds = null; taskManager.AddTask(delegate { taskManager.UpdateProgress("Finding valid devices for build"); validTargetIds = DeploymentTargetManager.FindValidTargetsForLaunchBuild(targetGroup, buildReport); if (!validTargetIds.Any <DeploymentTargetId>()) { throw new PostprocessBuildPlayer.NoTargetsFoundException("Could not find any valid targets for build"); } }); taskManager.AddTask(delegate { foreach (DeploymentTargetId current in validTargetIds) { bool flag = current == validTargetIds[validTargetIds.Count - 1]; try { DeploymentTargetManager.LaunchBuildOnTarget(targetGroup, buildReport, current, taskManager.SpawnProgressHandlerFromCurrentTask()); return; } catch (OperationFailedException ex2) { UnityEngine.Debug.LogException(ex2); if (flag) { throw ex2; } } } throw new PostprocessBuildPlayer.NoTargetsFoundException("Could not find any target that managed to launch build"); }); taskManager.Run(); } catch (OperationFailedException ex) { UnityEngine.Debug.LogException(ex); EditorUtility.DisplayDialog(ex.title, ex.Message, "Ok"); } catch (OperationAbortedException) { Console.WriteLine("Deployment aborted"); } catch (PostprocessBuildPlayer.NoTargetsFoundException) { throw new UnityException(string.Format("Could not find any valid targets to launch on for {0}", buildTarget)); } catch (NotSupportedException) { IBuildPostprocessor buildPostProcessor = ModuleManager.GetBuildPostProcessor(targetGroup, buildTarget); if (buildPostProcessor == null) { throw new UnityException(string.Format("Launching {0} build target via mono is not supported", buildTarget)); } BuildLaunchPlayerArgs args; args.target = buildTarget; args.playerPackage = BuildPipeline.GetPlaybackEngineDirectory(buildTarget, options); args.installPath = path; args.productName = productName; args.options = options; buildPostProcessor.LaunchPlayer(args); } }