DisplayCancelableProgressBar() private method

private DisplayCancelableProgressBar ( string title, string info, float progress ) : bool
title string
info string
progress float
return bool
        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));
            }
        }
示例#2
0
        void Refresh()
        {
            mTarget.Ip = BuildConfig.LocalIpAddress();

            var newGroups = new BundleManifest();
            var groups    = Directory.GetDirectories(BuildConfig.BundleResRoot, "*", SearchOption.TopDirectoryOnly);
            int n         = 0;

            foreach (var group in groups)
            {
                EditorUtility.DisplayCancelableProgressBar("update group ...", group, (float)(++n) / groups.Length);

                var       groupName = group.upath().Replace(BuildConfig.BundleResRoot, "");
                GroupInfo groupInfo = mTarget.Groups.Find(i => i.Name == groupName);
                if (groupInfo == null)
                {
                    groupInfo = new GroupInfo()
                    {
                        Name     = groupName,
                        Bundles  = new List <BundleInfo>(),
                        mRebuild = true,
                    };
                }

                var newBundles = new List <BundleInfo>();
                foreach (var bundle in Directory.GetDirectories(group, "*", SearchOption.TopDirectoryOnly))
                {
                    var bundlePath  = bundle.upath();
                    var bundleName  = bundlePath.Replace(BuildConfig.BundleResRoot, "") + BuildConfig.BundlePostfix;
                    var assetBundle = AssetImporter.GetAtPath(bundlePath);
                    if (assetBundle != null)
                    {
                        assetBundle.assetBundleName = bundleName;
                    }

                    //var bundleName = bundle.upath().Replace(group + "/", "");
                    var bundleInfo = groupInfo.Bundles.Find(i => i.Name == bundleName);
                    if (bundleInfo == null)
                    {
                        bundleInfo      = new BundleInfo();
                        bundleInfo.Name = bundleName;
                    }

                    foreach (var f in Directory.GetFiles(bundle, "*", SearchOption.AllDirectories)
                             .Where(i => !i.EndsWith(".meta")))
                    {
                        var assetImporter = AssetImporter.GetAtPath(f);
                        if (assetImporter != null)
                        {
                            assetImporter.assetBundleName = bundleName; //"";//
                            var assetTimeStamp = assetImporter.assetTimeStamp;
                        }
                    }

                    // if (time > 0)
                    newBundles.Add(bundleInfo);
                } //for 2

                //            AssetDatabase.GetAllAssetBundleNames();
                // AssetDatabase.RemoveUnusedAssetBundleNames();

                groupInfo.Bundles = newBundles;
                groupInfo.Refresh();

                if (groupInfo.Bundles.Count > 0)
                {
                    newGroups.Add(groupInfo);
                }
            } //for 1

            mTarget.Groups = newGroups;

            EditorUtility.ClearProgressBar();
        }
示例#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);
     }
 }
示例#4
0
        public static IEnumerator Execute(string exe, string prmt
                                          , System.Diagnostics.DataReceivedEventHandler OutputDataReceived = null
                                          , Action end  = null
                                          , float total = 0, string processingtag = "bash", string info = ""
                                          )
        {
            bool finished   = false;
            var  process    = new System.Diagnostics.Process();
            var  processing = 0f;

            try
            {
                // UnityEngine.Debug.Log(exe + " " + prmt);
                var pi = new System.Diagnostics.ProcessStartInfo(exe, prmt);
                pi.WorkingDirectory       = ".";
                pi.RedirectStandardInput  = false;
                pi.RedirectStandardOutput = true;
                pi.RedirectStandardError  = true;
                pi.UseShellExecute        = false;
                pi.CreateNoWindow         = true;

                if (OutputDataReceived != null)
                {
                    process.OutputDataReceived += OutputDataReceived;
                }
                process.OutputDataReceived += (sender, e) =>
                {
                    if (string.IsNullOrEmpty(e.Data))
                    {
                        return;
                    }
                    if (e.Data.StartsWith(processingtag))
                    {
                        ++processing;
                    }
                    // UnityEngine.Debug.Log(e.Data);
                };
                process.ErrorDataReceived += (sender, e) =>
                {
                    if (!string.IsNullOrEmpty(e.Data))
                    {
                        UnityEngine.Debug.LogError(e.GetType() + ": " + e.Data);
                    }
                };
                process.Exited += (object sender, EventArgs e) =>
                {
                    finished = true;
                    UnityEngine.Debug.Log("Exit");
                };

                process.StartInfo           = pi;
                process.EnableRaisingEvents = true;
                process.Start();
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();
                // process.WaitForExit();
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogError("catch: " + e);
            }

            while (!finished)
            {
                if (total > 1)
                {
                    EditorUtility.DisplayCancelableProgressBar("uploading ...", info + ": " + processing + "/" + total,
                                                               processing / total);
                }

                yield return(null);
            }

            if (end != null)
            {
                end();
            }

            // UnityEngine.Debug.Log("finished: " + process.ExitCode);
            EditorUtility.ClearProgressBar();
            yield return(null);
        }