Exemple #1
0
        IEnumerator DoTask(DirectoryInfo dir)
        {
            long total = 0;

            System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch();
            w.Start();

            var container = new ArchiveContainer();

            progressBar.Progress  = 0f;
            progressBar.Enable    = true;
            progressBar.Title     = "Loading";
            progressBar.TipFormat = "Loading AssetBundle, please wait.Progress: {0:0.00} %";
            var loadResult = container.Load(dir, buildVM.GetDecryptor());

            while (!loadResult.IsDone)
            {
                if (cancel)
                {
                    loadResult.Cancel();
                }

                progressBar.Progress = loadResult.Progress;

                yield return(null);
            }
            w.Stop();
            total += w.ElapsedMilliseconds;
            Debug.LogFormat("loading time: {0} milliseconds", w.ElapsedMilliseconds);

            if (loadResult.Exception != null)
            {
                Debug.LogErrorFormat("{0}", loadResult.Exception);

                progressBar.Enable = false;
                if (container != null)
                {
                    container.Dispose();
                    container = null;
                }
                yield break;
            }

            w.Reset();
            w.Start();

            var analyzer = new RedundancyAnalyzer(container);

            progressBar.Progress  = 0f;
            progressBar.Enable    = true;
            progressBar.Title     = "Redundancy Analysis";
            progressBar.TipFormat = "Analyzing asset redundancy,please wait.Progress: {0:0.00} %";
            var analyzeResult = analyzer.AnalyzeRedundancy();

            while (!analyzeResult.IsDone)
            {
                if (cancel)
                {
                    analyzeResult.Cancel();
                }

                progressBar.Progress = analyzeResult.Progress;

                yield return(null);
            }

            if (analyzeResult.Exception != null)
            {
                Debug.LogErrorFormat("{0}", analyzeResult.Exception);

                progressBar.Enable = false;
                if (container != null)
                {
                    container.Dispose();
                    container = null;
                }
                yield break;
            }
            w.Stop();
            total += w.ElapsedMilliseconds;
            Debug.LogFormat("analyzing time: {0} milliseconds", w.ElapsedMilliseconds);
            Debug.LogFormat("total time: {0} milliseconds", total);

            RedundancyReport report   = analyzeResult.Result;
            FileInfo         fileInfo = new FileInfo(string.Format(@"{0}\RedundancyReport-{1}.csv", dir.Parent.FullName, dir.Name));
            string           text     = ToCSV(report);

            File.WriteAllText(fileInfo.FullName, text);

            EditorApplication.delayCall += () =>
            {
                try
                {
                    //open the folder
                    EditorUtility.OpenWithDefaultApp(fileInfo.Directory.FullName);
                }
                catch (Exception) { }
            };

            progressBar.Enable = false;
            if (container != null)
            {
                container.Dispose();
                container = null;
            }
            analyzer = null;
        }
 public static IProgressResult <float> Load(this ArchiveContainer container, DirectoryInfo dir)
 {
     return(container.Load(dir, null));
 }