public static void Launch(BuildTarget target, string path, string productName, BuildOptions options)
        {
            BuildLaunchPlayerArgs args;
            IBuildPostprocessor   buildPostProcessor = ModuleManager.GetBuildPostProcessor(target);

            if (buildPostProcessor == null)
            {
                throw new UnityException($"Launching {target} build target via mono is not supported");
            }
            args.target        = target;
            args.playerPackage = BuildPipeline.GetPlaybackEngineDirectory(target, options);
            args.installPath   = path;
            args.productName   = productName;
            args.options       = options;
            buildPostProcessor.LaunchPlayer(args);
        }
        public static void Launch(BuildTargetGroup targetGroup, BuildTarget buildTarget, string path, string productName, BuildOptions options, BuildReport buildReport)
        {
            IBuildPostprocessor buildPostProcessor = ModuleManager.GetBuildPostProcessor(targetGroup, buildTarget);

            if (buildPostProcessor != null)
            {
                BuildLaunchPlayerArgs args;
                args.target        = buildTarget;
                args.playerPackage = BuildPipeline.GetPlaybackEngineDirectory(buildTarget, options);
                args.installPath   = path;
                args.productName   = productName;
                args.options       = options;
                args.report        = buildReport;
                buildPostProcessor.LaunchPlayer(args);
                return;
            }
            throw new UnityException(string.Format("Launching for target group {0}, build target {1} is not supported: There is no build post-processor available.", targetGroup, buildTarget));
        }
예제 #3
0
 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);
     }
 }