Example #1
0
 /// <summary>
 /// 导出系列打包器
 /// </summary>
 /// <param name="exports"></param>
 public static void ProductExport(KBuild_Base[] exports)
 {
     foreach (var export in exports)
     {
         ProductExport(export);
     }
 }
Example #2
0
        public static void ProductExport(KBuild_Base export)
        {
            Log.Info("Start Auto Build... {0}", export.GetType().Name);

            var time = DateTime.Now;

            try
            {
                string   ext = export.GetExtention();
                string[] itemArray;

                if (ext.StartsWith("dir:")) // 目錄下的所有文件,包括子文件夾
                {
                    string newExt = ext.Replace("dir:", "");
                    itemArray = Directory.GetFiles("Assets/" + export.GetResourceBuildDir() + "/" + export.GetDirectory(),
                                                   newExt, SearchOption.AllDirectories);
                }
                else if (ext == "dir")
                {
                    itemArray =
                        Directory.GetDirectories("Assets/" + export.GetResourceBuildDir() + "/" + export.GetDirectory());
                }
                else if (ext == "")
                {
                    itemArray = new string[0];
                }
                else
                {
                    itemArray = Directory.GetFiles("Assets/" + export.GetResourceBuildDir() + "/" + export.GetDirectory(),
                                                   export.GetExtention()); // 不包括子文件夾
                }
                export.BeforeExport();
                int okItemCount = 0;
                foreach (string item in itemArray)
                {
                    var cleanPath = item.Replace("\\", "/");

                    if (!export.FilterPath(cleanPath))
                    {
                        continue;
                    }
                    okItemCount++;
                    EditorUtility.DisplayCancelableProgressBar("[ProductExport]", cleanPath, .5f);
                    try
                    {
                        export.Export(cleanPath);
                    }
                    finally
                    {
                        EditorUtility.ClearProgressBar();
                    }

                    GC.Collect();
                    Resources.UnloadUnusedAssets();
                }
                export.AfterExport();


                Log.Info("Finish Auto Build: {0}, ItemsCount: {1}, Used Time: {2}", export.GetType().Name,
                         okItemCount, DateTime.Now - time);
            }
            catch (Exception e)
            {
                Log.Error("[Fail] Auto Build... {0}, Exception: {1}, Used Time: {2}, CurrentScene: {3}, Stack: {4}",
                          export.GetType().Name,
                          e.Message + "," + (e.InnerException != null ? e.InnerException.Message : ""), DateTime.Now - time,
#if UNITY_5 || UNITY_2017_1_OR_NEWER
                          EditorSceneManager.GetActiveScene().path,
#else
                          EditorApplication.currentScene,
#endif
                          e.StackTrace);
            }

            GC.Collect();
        }
Example #3
0
        public static void ProductExport(KBuild_Base export)
        {
            Log.Info("Start Auto Build... {0}", export.GetType().Name);

            var time = DateTime.Now;
            try
            {
                string ext = export.GetExtention();
                string[] itemArray;

                if (ext.StartsWith("dir:")) // 目錄下的所有文件,包括子文件夾
                {
                    string newExt = ext.Replace("dir:", "");
                    itemArray = Directory.GetFiles("Assets/" + export.GetResourceBuildDir() + "/" + export.GetDirectory(),
                        newExt, SearchOption.AllDirectories);
                }
                else if (ext == "dir")
                    itemArray =
                        Directory.GetDirectories("Assets/" + export.GetResourceBuildDir() + "/" + export.GetDirectory());
                else if (ext == "")
                    itemArray = new string[0];
                else
                    itemArray = Directory.GetFiles("Assets/" + export.GetResourceBuildDir() + "/" + export.GetDirectory(),
                        export.GetExtention()); // 不包括子文件夾

                export.BeforeExport();
                int okItemCount = 0;
                foreach (string item in itemArray)
                {
                    var cleanPath = item.Replace("\\", "/");

                    if (!export.FilterPath(cleanPath))
                        continue;
                    okItemCount++;
                    EditorUtility.DisplayCancelableProgressBar("[ProductExport]", cleanPath, .5f);
                    try
                    {
                        export.Export(cleanPath);
                    }
                    finally
                    {
                        EditorUtility.ClearProgressBar();
                    }

                    GC.Collect();
                    Resources.UnloadUnusedAssets();
                }
                export.AfterExport();

                Log.Info("Finish Auto Build: {0}, ItemsCount: {1}, Used Time: {2}", export.GetType().Name,
                    okItemCount, DateTime.Now - time);
            }
            catch (Exception e)
            {
                Log.Error("[Fail] Auto Build... {0}, Exception: {1}, Used Time: {2}, CurrentScene: {3}, Stack: {4}",
                    export.GetType().Name,
                    e.Message + "," + (e.InnerException != null ? e.InnerException.Message : ""), DateTime.Now - time,
            #if UNITY_5
                    EditorSceneManager.GetActiveScene().path,
            #else
                    EditorApplication.currentScene,
            #endif
                    e.StackTrace);
            }

            GC.Collect();
        }