public static void MenuOpenAbConfig() { ABConfig instance = ABConfig.LoadAbConfig(); if (instance == null) { // Create Resources folder if it doesn't exist. EdgeFrameworkConst.ResourcesFolder.CreateDirIfNotExists(); // Now create the asset inside the Resources folder. instance = ABConfig.Instance; // this will create a new instance of the EMSettings scriptable. AssetDatabase.CreateAsset(instance, EdgeFrameworkConst.AbConfigPath); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Debug.Log("AbConfig.asset was created at " + EdgeFrameworkConst.AbConfigPath); } Selection.activeObject = instance; }
public static void Build(bool hotfix = false, string abmd5Path = "", string hotCount = "1", string des = "") { if (string.IsNullOrEmpty(ABAddress.ABBYTEPATH)) { Debug.LogError("RealFramConfig中未配置abBytePath路径!!!"); return; } // DataEditor.AllXmlToBinary(); mAllFileAB.Clear(); mAllFileDir.Clear(); mAllPrefabDir.Clear(); mConfigFil.Clear(); ABConfig abConfig = AssetDatabase.LoadAssetAtPath <ABConfig>(EdgeFrameworkConst.AbConfigPath); if (abConfig.allFileDirAb.Count <= 0 && abConfig.allPrefabPath.Count <= 0) { Debug.LogError("请在菜单栏EdgeFramework->OpenTool->AbConfig中配置需要打包AssetBundle的文件"); return; } if (abConfig.allFileDirAb.Count > 0) { foreach (ABConfig.FileDirABName fileDir in abConfig.allFileDirAb) { //Debug.Log(fileDir.Path); if (mAllFileDir.ContainsKey(fileDir.abName)) { Debug.LogError("Ab包配置名字重复,请检查!"); } else { string datapath = Application.dataPath; datapath = datapath.Replace("Assets", ""); if (!Directory.Exists(datapath + fileDir.path)) { Debug.LogError("All File Dir Ab中不存在" + fileDir.abName + "路径," + fileDir.path); } else { mAllFileDir.Add(fileDir.abName, fileDir.path); mAllFileAB.Add(fileDir.path); mConfigFil.Add(fileDir.path); } } } } if (abConfig.allPrefabPath.Count > 0) { string[] allStr = AssetDatabase.FindAssets("t:Prefab", abConfig.allPrefabPath.ToArray()); for (int i = 0; i < allStr.Length; i++) { string path = AssetDatabase.GUIDToAssetPath(allStr[i]); EditorUtility.DisplayProgressBar("查找Prefab", "Prefab:" + path, i * 1.0f / allStr.Length); mConfigFil.Add(path); if (!ContainAllFileAB(path)) { GameObject obj = AssetDatabase.LoadAssetAtPath <GameObject>(path); string[] allDepentd = AssetDatabase.GetDependencies(path); List <string> allDependPath = new List <string>(); for (int j = 0; j < allDepentd.Length; j++) { // Debug.Log(allDepentd[j]); if (!ContainAllFileAB(allDepentd[j]) && !allDepentd[j].EndsWith(".cs")) { mAllFileAB.Add(allDepentd[j]); allDependPath.Add(allDepentd[j]); } } if (mAllPrefabDir.ContainsKey(obj.name)) { Debug.LogError("存在相同名字的Prefab!Prefab:" + path); } else { mAllPrefabDir.Add(obj.name, allDependPath); } } } } foreach (string name in mAllFileDir.Keys) { SetABName(name, mAllFileDir[name]); } foreach (var name in mAllPrefabDir.Keys) { SetABName(name, mAllPrefabDir[name]); } BunildAssetBundle(); string[] oldAbNames = AssetDatabase.GetAllAssetBundleNames(); for (int i = 0; i < oldAbNames.Length; i++) { AssetDatabase.RemoveAssetBundleName(oldAbNames[i], true); EditorUtility.DisplayProgressBar("清除Ab包名", "名字:" + oldAbNames, i * 1.0f / oldAbNames.Length); } if (hotfix) { ReadMd5Com(abmd5Path, hotCount, des); } else { WriteABMD5(); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EditorUtility.ClearProgressBar(); }