protected override void OnRender()
        {
            if (IsEnable)
            {
                if (GUILayout.Button("Del Config", GUILayout.ExpandWidth(false)))
                {
                    IsEnable = false;
                    string filePath = Path.Combine(EAssetBundleToolUtil.GetDiskPath(ModuleRoot.RootPath), "_.config.txt");
                    File.Delete(filePath);
                    File.Delete(filePath + ".meta");
                    ModuleRoot.RemoveAllComponentsOfChild();
                    AssetDatabase.Refresh();
                }
            }
            else
            {
                if (GUILayout.Button("Create Config", GUILayout.ExpandWidth(false)))
                {
                    IsEnable = true;
                    string filePath = Path.Combine(EAssetBundleToolUtil.GetDiskPath(ModuleRoot.RootPath), "_.config.txt");
                    File.WriteAllText(filePath, "");

                    foreach (var v in ModuleRoot.Tree)
                    {
                        v.SetComponent(new EGUIComponentFolderItem(v));
                    }

                    AssetDatabase.Refresh();
                }
            }
        }
 /// <summary>
 /// 重新载入文件树结构的数据
 /// </summary>
 void ReloadFolderData()
 {
     foreach (var v in TreeRoot.Tree)
     {
         string fPath    = EAssetBundleToolUtil.GetDiskPath(v.RootPath + "/_.config.txt");
         bool   isEnable = File.Exists(fPath);
         v.SetComponent(new EGUIComponentFolderModule(isEnable, v));
         if (isEnable)
         {
             v.GetComponent <EGUIComponentFolderModule>().SetConfigMap(EAssetBundleToolUtil.StringToConfigMap(File.ReadAllText(fPath)));
         }
     }
 }
 /// <summary>
 /// 点击存储将模块下的配置属性写入本地文件_.config.txt
 /// </summary>
 void OnClickSave()
 {
     foreach (var v in TreeRoot.Tree)
     {
         string fPath     = EAssetBundleToolUtil.GetDiskPath(v.RootPath + "/_.config.txt");
         var    component = v.GetComponent <EGUIComponentFolderModule>();
         Dictionary <string, List <string> > outConfigMap;
         if (component.TryGetConfigMap(out outConfigMap))
         {
             File.WriteAllText(fPath, EAssetBundleToolUtil.ConfigMapToString(outConfigMap));
         }
     }
     AssetDatabase.Refresh();
 }
Esempio n. 4
0
        /// <summary>
        /// 清除被选中模块AssetBundle的名称
        /// </summary>
        void OnClearAssetBundleName()
        {
            var foldersObject = FolderList.GetChooseFolder();

            foreach (var v in foldersObject)
            {
                EAssetBundleToolUtil.ClearAssetBundleName(v.RelativePath);
                System.IO.File.Delete(EAssetBundleToolUtil.GetDiskPath(v.RelativePath + "/manifest.txt"));
                System.IO.File.Delete(EAssetBundleToolUtil.GetDiskPath(v.RelativePath + "/manifest.txt.meta"));
                OnClearModuleName(v.FolderName, v.RelativePath);
            }
            AssetDatabase.Refresh();
            Debug.Log("Clear AssetBundle Name Complete!");
        }
Esempio n. 5
0
        public static FileVersionInfo GetVersionInfoByFile(string _parentPath, string _filePath, string _moduleName)
        {
            FileVersionInfo info         = new FileVersionInfo();
            int             parentDirLen = _parentPath.Length;
            FileInfo        finfo        = new FileInfo(_filePath);
            long            outLength;
            var             suburl = _filePath.Substring(parentDirLen);
            MD5             md5    = new MD5CryptoServiceProvider();
            var             strMd5 = EAssetBundleToolUtil.GetMD5(md5, _filePath, out outLength);

            info.Size         = outLength;
            info.MD5          = strMd5;
            info.FileName     = finfo.Name;
            info.RelativePath = suburl;
            info.ModuleName   = _moduleName;
            //md5.Dispose();
            return(info);
        }
Esempio n. 6
0
        public static List <FileVersionInfo> GetVersionListOfModule(string _parentPath, string _inputPath, string _moduleName, string _searchPattern)
        {
            List <FileVersionInfo> result = new List <FileVersionInfo>();
            var files        = Directory.GetFiles(_inputPath, _searchPattern, SearchOption.AllDirectories);
            int parentDirLen = _parentPath.Length;
            MD5 md5          = new MD5CryptoServiceProvider();

            foreach (var v in  files)
            {
                FileVersionInfo info  = new FileVersionInfo();
                FileInfo        finfo = new FileInfo(v);
                long            outLength;
                var             suburl = v.Substring(parentDirLen);
                var             strMd5 = EAssetBundleToolUtil.GetMD5(md5, v, out outLength);
                info.Size         = outLength;
                info.MD5          = strMd5;
                info.FileName     = finfo.Name;
                info.RelativePath = suburl;
                info.ModuleName   = _moduleName;
                result.Add(info);
            }
            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// 设置被选中模块AssetBundle的名称
        /// </summary>
        void OnSetAssetBundleName()
        {
            var foldersObject = FolderList.GetChooseFolder();

            for (int i = 0; i < foldersObject.Count; i++)
            {
                var    v          = foldersObject[i];
                string moduleName = v.FolderName.ToLower();
                OnSetModuleName(v.FolderName, v.RelativePath);
                EAssetBundleToolUtil.SetAssetBundleName(v.RelativePath, moduleName, Config.AssetBundleExtension, EventOnInvalidFile);
                TextAsset config = AssetDatabase.LoadAssetAtPath <TextAsset>(v.RelativePath + "/_.config.txt");
                if (config != null)
                {
                    Dictionary <string, List <string> > define = EAssetBundleToolUtil.GetNameConfig(config.text);
                    if (define.ContainsKey("Group"))
                    {
                        EAssetBundleToolUtil.SetAssetBundleNameByGroupList(v.RelativePath, moduleName, define["Group"], Config.AssetBundleExtension);
                    }
                    if (define.ContainsKey("Single"))
                    {
                        EAssetBundleToolUtil.SetAssetBundleNameBySingleList(v.RelativePath, moduleName, define["Single"], Config.AssetBundleExtension);
                    }
                }
                EAssetBundleToolUtil.UnsetAssetBundleName(v.RelativePath, Config.NotAssetBundleFolderName);
                EditorUtility.DisplayProgressBar("Set AssetBundle Name", v.FolderName, (i + 1) / foldersObject.Count * 0.5f);
            }

            for (int i = 0; i < foldersObject.Count; i++)
            {
                var v = foldersObject[i];
                EAssetBundleToolUtil.CreateModuleManifest(v.RelativePath, v.FolderName.ToLower(), Config.AssetBundleExtension);
                EditorUtility.DisplayProgressBar("Create Manifest File", v.FolderName, (i + 1) / foldersObject.Count * 0.5f + 0.5f);
            }
            EditorUtility.ClearProgressBar();
            Debug.Log("Set AssetBundle Name Complete!");
        }
Esempio n. 8
0
        /// <summary>
        /// 点击输出AssetBundle文件
        /// </summary>
        void OnClickOutputAssetBundle()
        {
            //> 确定目标平台
            BuildTarget selection = EditorUserBuildSettings.activeBuildTarget;

            if (BuildTargetDropdown.Visible)
            {
                selection = (BuildTarget)BuildTargetDropdown.Value;
            }

            //> 确定输出模块
            var foldersObject = FolderList.GetChooseFolder();

            if (foldersObject.Count == 0)
            {
                Debug.LogError("Invalid build:Chose at least one module.");
            }

            AssetDatabase.RemoveUnusedAssetBundleNames();
            var allAssetBundleNames = AssetDatabase.GetAllAssetBundleNames();
            var outputPath1         = EAssetBundleToolUtil.GetDiskPath("AssetBundlePool/" + selection.ToString());
            var outputPath2         = EAssetBundleToolUtil.GetDiskPath(Config.AssetBundleOutput + "/" + selection.ToString());

            if (!Directory.Exists(outputPath1))
            {
                Directory.CreateDirectory(outputPath1);
            }
            if (!Directory.Exists(outputPath2))
            {
                Directory.CreateDirectory(outputPath2);
            }

            List <FileVersionInfo> versionList = new List <FileVersionInfo>();

            //> 构建AB文件到资源池
            foreach (var v in foldersObject)
            {
                var names = EAssetBundleToolUtil.GetAssetBundleNamesByModule(allAssetBundleNames, v.FolderName.ToLower());

                var buildMap = EAssetBundleToolUtil.GetBuildMapByAssetBundleNames(names);

                if (buildMap.Count == 0)
                {
                    continue;
                }

                string finalOutputPath1 = outputPath1;
                string finalOutputPath2 = outputPath2;
                if (Config.IsModuleStructure)
                {
                    finalOutputPath1 += "/" + v.FolderName.ToLower();
                    finalOutputPath2 += "/" + v.FolderName.ToLower();
                    if (!Directory.Exists(finalOutputPath1))
                    {
                        Directory.CreateDirectory(finalOutputPath1);
                    }
                    if (!Directory.Exists(finalOutputPath2))
                    {
                        Directory.CreateDirectory(finalOutputPath2);
                    }
                }

                BuildPipeline.BuildAssetBundles(finalOutputPath1, buildMap.ToArray(), BuildAssetBundleOptions.StrictMode, selection);
                //> 拷贝AB文件到输出目录
                List <FileVersionInfo> moduleVersion = new List <FileVersionInfo>();

                foreach (var f in names)
                {
                    if (File.Exists(finalOutputPath1 + "/" + f))
                    {
                        File.Copy(finalOutputPath1 + "/" + f, finalOutputPath2 + "/" + f, true);
                        //> 创建版本文件信息
                        moduleVersion.Add(TiyVersionListCreator.GetVersionInfoByFile(outputPath2, finalOutputPath2 + "/" + f, v.FolderName.ToLower()));
                    }
                    else
                    {
                        Debug.LogErrorFormat("File is missing:{0}", finalOutputPath1 + "/" + f);
                    }
                }

                if (Config.IsCreateVersionList)
                {
                    if (Config.IsModuleStructureForVersion)
                    {
                        string versionFilePath = "";
                        if (Config.IsModuleStructure)
                        {
                            versionFilePath = outputPath2 + "/" + v.FolderName.ToLower() + "/" + "version.list";
                        }
                        else
                        {
                            versionFilePath = outputPath2 + "/" + v.FolderName.ToLower() + "." + "version.list";
                        }
                        TiyVersionListCreator.CreateVersionListByTemplate(moduleVersion, Config.FullVersionListTemplateFile, versionFilePath);
                    }
                    else
                    {
                        versionList.AddRange(moduleVersion);
                    }
                }
            }

            if (Config.IsCreateVersionList && versionList.Count > 0)
            {
                TiyVersionListCreator.CreateVersionListByTemplate(versionList, Config.FullVersionListTemplateFile, outputPath2 + "/version.list");
            }


            System.Diagnostics.Process.Start(outputPath2);
            Debug.Log("Build Complete!");
            GUIUtility.ExitGUI();
        }