public void ExcelToTxt() { string[,] ExcelInfo = ExcelHelper.GetFirstSheetInfo(excelPath); for (int j = 1; j < ExcelInfo.GetLength(1); j++) { string oneLanuage = ""; for (int i = 1; i < ExcelInfo.GetLength(0); i++) { if (i != 1) { oneLanuage += "\n"; } oneLanuage += ExcelInfo[i, 0] + "=" + ExcelInfo[i, j].Replace("=", "#"); } oneLanuage = oneLanuage.Replace("\n\n", "\n"); if (!LanuageNameToPath.ContainsKey(ExcelInfo[0, j])) { AFLogger.EditorErrorLog("请注意Excel表格与LanuageNameToPath的对应!"); return; } FileHelper.CreatFile(LanuageNameToPath[ExcelInfo[0, j]], System.Text.Encoding.UTF8.GetBytes(oneLanuage), true); } AFLogger.d("Excel表格转TXT文件转换完成!"); }
public void CalculateProcess(string ResClass, string ABKey, double process, bool isFinish) { allprocess = (CurSize + process * newClassInfo.ABName[ABKey]) / totalSize; if (isFinish) { CurSize += newClassInfo.ABName[ABKey]; if (oldClassInfo != null) { oldClassInfo.ABName[ABKey] = newClassInfo.ABName[ABKey]; } Debug.Log("CurSize : " + CurSize + " totalSize:" + totalSize); if (CurSize.Equals(totalSize)) { //覆盖本地info.txt FileHelper.CreatFile(ABHotUpdate.Instance.GetSavePathByClass(ResClass, false), System.Text.Encoding.UTF8.GetBytes(SerializeHelper.ToJson(newClassInfo))); ABprocessevent.InvokeGracefully(1, true, DownStatus.Sucess, ""); } else { ABprocessevent.InvokeGracefully(allprocess, false, DownStatus.Downloding, ""); } } else { ABprocessevent.InvokeGracefully(allprocess, isFinish, DownStatus.Sucess, ""); } }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <param name="webRequestGetEvent"></param> /// <param name="SavePath">如果为""则不需要保存</param> /// <param name="isReturnPath">默认是返回内容</param> /// <returns></returns> public IEnumerator RealWebRequest(string url, WebRequestNetTextureEvent webRequestGetEvent, string savePath = "") { webRequest = UnityWebRequestTexture.GetTexture(url); httpRequestCount += 1; yield return(webRequest.SendWebRequest()); if (webRequest.error == null || webRequest.error == "") { Texture2D texture2D = DownloadHandlerTexture.GetContent(webRequest); if (savePath != null && savePath != "") { FileHelper.CreatFile(savePath, texture2D.EncodeToPNG()); } webRequestGetEvent(texture2D, savePath, DownStatus.Sucess, ""); webRequest = null; } else { webRequest = null; DownManager.Instance.DebugDownError(httpRequestCount, url, webRequest.error); if (httpRequestCount <= 3) { IEnumeratorTool.StartCoroutine(RealWebRequest(url, webRequestGetEvent)); } else { if (webRequestGetEvent != null) { webRequestGetEvent.Invoke(default(Texture2D), savePath, DownStatus.Fail, webRequest.error); } } } }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <param name="webRequestGetEvent"></param> /// <param name="SavePath">如果为""则不需要保存</param> /// <param name="isReturnPath">默认是返回内容</param> /// <returns></returns> public IEnumerator RealWebRequest(string url, WebRequestTextEvent webRequestGetEvent, string SavePath = "", bool isReturnPath = false) { UnityWebRequest webRequest = UnityWebRequest.Get(url); httpRequestCount += 1; yield return(webRequest.SendWebRequest()); if (webRequest.error == null || webRequest.error == "") { if (SavePath != null && SavePath != "") { FileHelper.CreatFile(SavePath, webRequest.downloadHandler.data, true); } if (isReturnPath) { if (webRequestGetEvent != null) { webRequestGetEvent.Invoke(SavePath, DownStatus.Sucess, ""); } } else { if (webRequestGetEvent != null) { webRequestGetEvent.Invoke(webRequest.downloadHandler.text, DownStatus.Sucess, ""); } } } else { DownManager.Instance.DebugDownError(httpRequestCount, url, webRequest.error); if (httpRequestCount <= 3) { DownManager.Instance.RegisterRequest(RealWebRequest(url, webRequestGetEvent, SavePath, isReturnPath)); } else { if (webRequestGetEvent != null) { webRequestGetEvent.Invoke("", DownStatus.Fail, webRequest.error); } } } }
public void SaveSetting() { XcodeSetting xcodeSetting = new XcodeSetting(); xcodeSetting.TeamID = TeamID; xcodeSetting.Version = Version; xcodeSetting.build = build; xcodeSetting.BundleIdentifier = BundleIdentifier; xcodeSetting.StaticlibraryDic = StaticlibraryList; xcodeSetting.buildPropertyDic = buildPropertyList; xcodeSetting.pListDataDic = pListDataList; xcodeSetting.urlSchemeDic = urlSchemeList; xcodeSetting.frameworkToProjectList = frameworkToProjectList; xcodeSetting.appQueriesSchemeList = appQueriesSchemeList; xcodeSetting.CopyFileDic = CopyFileDic; xcodeSetting.CopyFolderDic = CopyFolderDic; xcodeSetting.FilesCompileFlagDIC = FilesCompileFlagDIC; FileHelper.CreatFile(XcodeSettingTxtPath, SerializeHelper.ToByteArray(xcodeSetting), true); }
/// <summary> /// MD5检测回调 /// </summary> public void ABMD5ResultCallback(ABClassDownInfo ABDowninfo, DownStatus downResult, string downError) { //从保存下载的字典里移除 RemoveDownload(ABDowninfo.ResClass, true, ABDataHolder.Instance.GetMD5DownURL() + ABDowninfo.ResClass.ToString() + "Info.txt"); AddProductDownInfo(ABDowninfo); //回调MD5的结果,可根据结果进行处理 ABDowninfo.ABMD5Callback.InvokeGracefully(ABDowninfo, downResult, downError); if (downResult == DownStatus.Sucess) { //Debug.Log("MD5检测结果:" + ABDowninfo.aBState); //这里分成了产品AB包和普通AB包,如果产品AB包需要直接下载,可在ABMD5callback回调中自己实现 if (ABDowninfo.isHasRecog) { if (ABDowninfo.aBState != ABState.Newest) { //覆盖本地info.txt FileHelper.CreatFile(GetSavePathByClass(ABDowninfo.ResClass, false), System.Text.Encoding.UTF8.GetBytes(SerializeHelper.ToJson(ABDowninfo.newClassInfo)), true); } } else { //Debug.Log("不是识别AB包的下载"); if (ABDowninfo.aBState == ABState.Newest) { //覆盖本地info.txt FileHelper.CreatFile(GetSavePathByClass(ABDowninfo.ResClass, false), System.Text.Encoding.UTF8.GetBytes(SerializeHelper.ToJson(ABDowninfo.newClassInfo)), true); //没有需要热更的 mABDownInfo[ABDowninfo.ResClass].IsDownFinish = true; //下载完成 ABDowninfo.ABprocessevent.InvokeGracefully(1, true, DownStatus.Sucess, ""); } else { //计算大小并下载 DownClassAB(ABDowninfo.ResClass); } } } }
public IEnumerator RealWebRequest(string url, string SavePath, WebRequestByteEvent webRequestGetEvent) { webRequest = UnityWebRequest.Get(url); httpRequestCount += 1; yield return(webRequest.SendWebRequest()); if (webRequest.error == null || webRequest.error == "") { if (SavePath != null && SavePath != "") { FileHelper.CreatFile(SavePath, webRequest.downloadHandler.data, true); } if (webRequestGetEvent != null) { webRequestGetEvent.Invoke(webRequest.downloadHandler.data, DownStatus.Sucess, ""); } webRequest = null; } else { webRequest = null; DownManager.Instance.DebugDownError(httpRequestCount, url, webRequest.error); if (httpRequestCount <= 3) { DownManager.Instance.RegisterRequest(RealWebRequest(url, SavePath, webRequestGetEvent)); } else { if (webRequestGetEvent != null) { webRequestGetEvent.Invoke(default(byte[]), DownStatus.Fail, webRequest.error); } } } }
public void OnStart() { FileHelper.CreatFile(PathTool.PersistentDataPath + "version.txt", System.Text.Encoding.UTF8.GetBytes("这是测试persistent读取数据的文本"), true); showPersistLoadContent.text = ResManager.Instance.LoadStr(PathTool.PersistentDataPath + "version.txt"); }
public static void Build() { m_BundleTargetPath = EditorAssetPath.ProjectPath + "AssetBundle/" + buildTarget.ToString() + "/"; AppInfoConfig appInfoConfig = AssetDatabasex.LoadAssetOfType <AppInfoConfig>("AppInfoConfig"); AF_ABConfig abConfig = AssetDatabasex.LoadAssetOfType <AF_ABConfig>("AF_ABConfig"); EditorAssetPath.InitABBuildPath(abConfig); //清空 m_ConfigFile.Clear(); m_AllFileAB.Clear(); m_AllFileDir.Clear(); m_AllPrefabDir.Clear(); string mTargetPath = EditorAssetPath.ABTargetPath; string mInfoPath = EditorAssetPath.ABInfoPath; if (abConfig.packageABType != PackageABType.PhoneAB) { mTargetPath = EditorAssetPath.ABTargetPath + buildTarget.ToString() + "/"; mInfoPath = EditorAssetPath.ABInfoPath + buildTarget.ToString() + "/"; } if (Directory.Exists(mTargetPath)) { FileUtil.DeleteFileOrDirectory(mTargetPath); } if (Directory.Exists(mInfoPath)) { FileUtil.DeleteFileOrDirectory(mInfoPath); } Directory.CreateDirectory(mInfoPath); Directory.CreateDirectory(mTargetPath); Directory.CreateDirectory(m_BundleTargetPath); //创建APP版本文件 FileHelper.CreatFile(EditorAssetPath.AppInfoPath, SerializeHelper.ToByteArray(appInfoConfig), true); Dictionary <string, bool> ClassToNeedPackageAB = new Dictionary <string, bool>(); for (int i = 0; i < abConfig.m_AllClass.Count; i++) { if (abConfig.m_AllClass[i].isSameAppType(abConfig.CurrentAppType)) { ClassToNeedPackageAB.Add(abConfig.m_AllClass[i].ABClassType, abConfig.m_AllClass[i].isNeedPackageAB); } } //剔除重复路径,将单个文件及文件夹的路径保存下来 //先处理文件夹再处理单个文件,因为有可能prefab依赖某个文件中的东西,所以要进行过滤 foreach (AF_OneAB oneAB in abConfig.m_AllFileAB) { bool isNeedPackageAB = false; for (int k = 0; k < oneAB.CategoryOfOwnership.Count; k++) { if (ClassToNeedPackageAB.ContainsKey(oneAB.CategoryOfOwnership[k]) && ClassToNeedPackageAB[oneAB.CategoryOfOwnership[k]]) { isNeedPackageAB = true; break; } } if (!isNeedPackageAB) { continue; } if (m_AllFileDir.ContainsKey(oneAB.mABIdentifier)) { AFLogger.EditorErrorLog("AB包配置名字重复,请检查!"); EditorUtility.ClearProgressBar(); } else { m_AllFileDir.Add(oneAB.mABIdentifier, oneAB.Path); //保存已打包的AB包路径 m_AllFileAB.Add(oneAB.Path); m_ConfigFile.Add(oneAB.Path); } } string[] AllPrefabsPath = abConfig.GetAllPrefabsPath(); if (AllPrefabsPath.Length > 0) { //获取路径下的所有prefab string[] allStr = AssetDatabase.FindAssets("t:Prefab", AllPrefabsPath); AFLogger.EditorInfoLog("获取的路径长度:" + allStr.Length); for (int i = 0; i < allStr.Length; i++) { bool isNeedPackageAB = false; for (int k = 0; k < abConfig.m_AllPrefabAB[i].CategoryOfOwnership.Count; k++) { if (ClassToNeedPackageAB.ContainsKey(abConfig.m_AllPrefabAB[i].CategoryOfOwnership[k]) && ClassToNeedPackageAB[abConfig.m_AllPrefabAB[i].CategoryOfOwnership[k]]) { isNeedPackageAB = true; break; } } if (!isNeedPackageAB) { continue; } //GUID转asset路径 string path = AssetDatabase.GUIDToAssetPath(allStr[i]); EditorUtility.DisplayProgressBar("查找Prefab", "Prefab:" + path, i * 1.0f / allStr.Length); m_ConfigFile.Add(path); if (!ContainAllFileAB(path)) { //获取资源的所有依赖 string[] allDepend = AssetDatabase.GetDependencies(path); List <string> allDependPath = new List <string>(); //遍历依赖文件 for (int j = 0; j < allDepend.Length; j++) { if (!ContainAllFileAB(allDepend[j]) && !allDepend[j].EndsWith(".cs", System.StringComparison.Ordinal)) { m_AllFileAB.Add(allDepend[j]); allDependPath.Add(allDepend[j]); } } if (m_AllPrefabDir.ContainsKey(abConfig.m_AllPrefabAB[i].mABIdentifier)) { AFLogger.EditorErrorLog("存在相同名字的Prefab!名字:" + abConfig.m_AllPrefabAB[i].mABIdentifier); EditorUtility.ClearProgressBar(); } else { m_AllPrefabDir.Add(abConfig.m_AllPrefabAB[i].mABIdentifier, allDependPath); } } } } //点击打包之后可以看见更改的文件的.meta文件改变 //文件夹设置ABName foreach (string name in m_AllFileDir.Keys) { SetABName(name, m_AllFileDir[name]); } //单个文件设置包名 foreach (string name in m_AllPrefabDir.Keys) { SetABName(name, m_AllPrefabDir[name]); } //打包 BunildAssetBundle(abConfig); //清除AB包名,因为上面更改了.meta文件,我们很多时候会使用svn或者git,有可能会导致一不小心上传特别乱 string[] oldABNames = AssetDatabase.GetAllAssetBundleNames(); for (int i = 0; i < oldABNames.Length; i++) { AssetDatabase.RemoveAssetBundleName(oldABNames[i], true); EditorUtility.DisplayProgressBar("清除AB包名", "名字:" + oldABNames[i], i * 1.0f / oldABNames.Length); } EditorUtility.ClearProgressBar(); //根据设置生成文件 ABBuildFinishEvent.BundleFinish(mTargetPath, m_BundleTargetPath, abConfig, mInfoPath, appInfoConfig); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EditorUtility.ClearProgressBar(); }