/// <summary> /// 执行保存到二进制中 /// </summary> /// <returns></returns> public override AssetAssemblyResult Execute() { AssetAddressAssemblyResult result = new AssetAddressAssemblyResult(); foreach (var group in m_AssetGroups) { group.Execute(result); } //读取配置 AssetBundleTagConfig tagConfig = Util.FileUtil.ReadFromBinary <AssetBundleTagConfig>(BundlePackUtil.GetTagConfigPath()); if (tagConfig.GroupDatas == null) { tagConfig.GroupDatas = new List <AssetBundleGroupData>(); } else { tagConfig.GroupDatas.Clear(); } foreach (var groupResult in result.m_GroupResults) { AssetAddressGroupResult gResult = groupResult as AssetAddressGroupResult; AssetBundleGroupData groupData = new AssetBundleGroupData(); groupData.GroupName = gResult.m_GroupName; groupData.IsGenAddress = gResult.m_IsGenAddress; groupData.IsMain = gResult.m_IsMain; groupData.IsPreload = gResult.m_IsPreload; tagConfig.GroupDatas.Add(groupData); foreach (var operationResult in gResult.m_OperationResults) { AssetAddressOperationResult oResult = operationResult as AssetAddressOperationResult; foreach (var kvp in oResult.m_AddressDataDic) { AssetAddressData aaData = new AssetAddressData(); AssetAddressData kvpValue = kvp.Value as AssetAddressData; aaData.AssetAddress = kvpValue.AssetAddress; aaData.AssetPath = kvpValue.AssetPath; aaData.BundlePath = kvpValue.BundlePath; aaData.Labels = new List <string>(kvpValue.Labels).ToArray(); groupData.AssetDatas.Add(aaData); } } } //保存配置 Util.FileUtil.SaveToBinary <AssetBundleTagConfig>(BundlePackUtil.GetTagConfigPath(), tagConfig); return(result); }
static public void SetName() { Debug.Log("SetName"); if (!Application.isPlaying) { bool result = BundlePackUtil.GenerateConfigs(true, true, true); if (!result) { if (EditorUtility.DisplayDialog("Warning", "Address Repeat!!!!\nDo you want to fix or view??", "OK", "Cancel")) { BundlePackWindow.ShowWin(); } } else { if (EditorUtility.DisplayDialog("Success", "Packed Success", "OK")) { AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } } } }
static public void CreatMD5() { Debug.Log("CreatMD5"); BundlePackConfig m_PackConfig = LeyoutechEditor.Core.Util.FileUtil.ReadFromBinary <BundlePackConfig>(BundlePackUtil.GetPackConfigPath()); string resPath = m_PackConfig.OutputDirPath; string newFilePath = resPath + "/files.txt";//创建版本文件列表 paths.Clear(); files.Clear(); if (File.Exists(newFilePath)) { File.Delete(newFilePath); } paths.Clear(); files.Clear(); Recursive(resPath); FileStream fs = new FileStream(newFilePath, FileMode.CreateNew); StreamWriter sw = new StreamWriter(fs); string luaAB = "";//用于处理 lua.ab 与 lua.ab.manifest 序列成同一个md5 string hashCode = ""; for (int i = 0; i < files.Count; i++) { string file = files[i]; string ext = Path.GetExtension(file); if (ext.Equals(".meta") || ext.Equals(".svn") || ext.Equals(".txt") || ext.Contains(".DS_Store") || ext.Contains(".exe") || ext.Contains(".bat")) { continue; } string md5 = ""; if (file.IndexOf("lua/") == -1) { md5 = FileUtility.MD5file(file); } else { if (luaAB != "" && file.IndexOf(luaAB) != -1) { md5 = hashCode; } else { md5 = FileUtility.MD5file(file); luaAB = file; hashCode = md5; } } string value = file.Replace(resPath, string.Empty); sw.WriteLine(value + "|" + md5); } //格式: v1.v2.v3.v4 其中 vx代表序号 //版号表示:v1程序更新(全部),v2(非UI)资源, v3 UI资源, v4 lua脚本 sw.WriteLine(appVersion + ".0.0.0"); sw.Close(); fs.Close(); AssetDatabase.Refresh(); }
static public void CopyTo() { Debug.Log("CopyTostreamingAssetsPath"); BundlePackConfig m_PackConfig = LeyoutechEditor.Core.Util.FileUtil.ReadFromBinary <BundlePackConfig>(BundlePackUtil.GetPackConfigPath()); FileUtility.CloneDirectory(m_PackConfig.OutputDirPath, Application.streamingAssetsPath); AssetDatabase.Refresh(); }
private void OnEnable() { AssetBundleTagConfig tagConfig = Util.FileUtil.ReadFromBinary <AssetBundleTagConfig>(BundlePackUtil.GetTagConfigPath()); m_Finder = BundlePackUtil.CreateAssetDependFinder(tagConfig, true); }