public List <string> GetExistPathFiles(string path, string endex) { string tempRealPath = path; string tempLow = path.ToLower(); for (int i = 0; i < mEncryPath.Length; i++) { var enc = mEncryPath[i]; if (enc.key == tempLow) { tempRealPath = enc.value; break; } } List <string> tempPaths = new List <string>(); for (int i = 0; i < mPahtList.Length; i++) { string pblkPath = NoPackAssetinstance.mPahtList[i] + "/" + tempRealPath; if (FEPath.Exists(pblkPath)) { tempPaths = FCommonFunction.GetFiles(pblkPath, tempPaths, endex); } } return(tempPaths); }
static void CreateZip() { UnityEngine.Object obj = Selection.activeObject; string setImgPath = AssetDatabase.GetAssetPath(obj); string filepath = Application.dataPath + "/" + setImgPath.Replace("Assets/", ""); var files = FZipTool.ZipDirectory(filepath, FEPath.GetDirectoryName(filepath) + "/", ".meta"); var t = FSaveHandle.Create(FEPath.GetDirectoryName(filepath) + "/version", FFilePath.FP_Abs, FOpenType.OT_Write | FOpenType.OT_Txt); string md5 = FCommonFunction.GetMD5HashFromFile(files); int type = EditorUserBuildSettings.activeBuildTarget != BuildTarget.iOS ? 0 : 1; t.SetContext("{\"version\":" + MyEdior.GetTimeVersion().ToString() + ",\"md5\":\"" + md5 + ",\"type\":\"" + type.ToString() + "\"}"); t.Save(); }
//绘制委托函数类 public static System.Delegate DrawDelegate(object ins, Delegate callObject, Type classType, Type outType, Type returnType, params Type[] paras) { var mode = classType.GetMethods(); List <MethodInfo> methods = new List <MethodInfo>(); for (int i = 0; i < mode.Length; i++) { var mo = mode[i]; var obj = mo.GetCustomAttributes(typeof(HideInInspector), true); if ((obj == null || obj.Length == 0) && mo.IsPublic && mo.ReturnParameter.ParameterType == returnType) { var parame = mo.GetParameters(); if (parame.Length == paras.Length) { bool IsFit = true; for (int p = 0; p < parame.Length; p++) { if (parame[p].ParameterType != paras[p]) { IsFit = false; break; } } if (IsFit) { methods.Add(mo); } } } } string selectName = ""; if (callObject != null) { var motd = callObject.Method; selectName = motd.Name; } int index = 0; List <string> methodName = new List <string>(); methodName.Add("Null"); FCommonFunction.SetList(methods, (f, i) => { if (f.Name == selectName) { index = i + 1; } methodName.Add(f.Name); }); int lastIndex = index; index = EditorGUILayout.Popup(index, methodName.ToArray()); if (index != lastIndex) { if (index == 0) { return(null); } else { return(System.Delegate.CreateDelegate(outType, ins, methods[index - 1])); } } return(callObject); }
public static void DeletFile(string path) { FCommonFunction.DeletFile(path); }
public static void CretatePartPack(bool isMain) { string copyPath = FEPath.GetDirectoryName(SceneManager.STREAMINGPATH.Replace("file://", "")); string newPath = copyPath.Replace("StreamingAssets", "_TempStreamingAssets"); FSaveHandle firstData = FSaveHandle.Create(copyPath + "/" + ResConfig.STREAMINGASSETSCONFIG, FFilePath.FP_Abs); if (!firstData.IsLoad) { Debug.LogError("没找到新配置文件:" + copyPath + "/" + ResConfig.STREAMINGASSETSCONFIG + "操作失败"); return; } BundleManager.StreamConfig firstStreamConfi = new BundleManager.StreamConfig(); firstData.FromObject(firstStreamConfi); MyEdior.DeletFile(newPath); MyEdior.CopyDirectory(copyPath, newPath); AssetDatabase.Refresh(); CreateConfig(newPath, firstStreamConfi, 0); string playFile = ""; string mainPack = copyPath.Replace("Assets/StreamingAssets", "FPartPack/MainPack"); if (isMain) { string copyPack = copyPath.Replace("Assets/StreamingAssets", "FTempCopyPack/Pack_" + DateTime.Now.ToString("MM_dd--HH_mm")); MyEdior.DeletFile(mainPack); FEPath.CreateDirectory(mainPack); EditorUtility.DisplayCancelableProgressBar("备份资源", "正在处理 ", 0.5f); File.Copy(newPath + "/" + ResConfig.STREAMINGASSETSCONFIG, mainPack + "/" + ResConfig.STREAMINGASSETSCONFIG, true); MyEdior.CopyDirectory(copyPath, copyPack + "/StreamingAssets"); File.Copy(newPath + "/" + ResConfig.STREAMINGASSETSCONFIG, copyPack + "/" + ResConfig.STREAMINGASSETSCONFIG, true); FZipTool.ZipDirectory(copyPack, FEPath.GetDirectoryName(copyPack) + "/"); MyEdior.DeletFile(copyPack); EditorUtility.ClearProgressBar(); playFile = mainPack; } else { //加载新配置 string newstreamingPath = newPath + "/" + ResConfig.STREAMINGASSETSCONFIG; FSaveHandle sd = FSaveHandle.Create(newstreamingPath, FFilePath.FP_Abs); if (sd == null) { Debug.LogError("没找到新配置文件:" + ResConfig.STREAMINGASSETSCONFIG + "对比文件失败"); } else { BundleManager.StreamConfig NewStreamConif = new BundleManager.StreamConfig(); sd.FromObject(NewStreamConif); //加载旧配置 string lastStremingPath = copyPath.Replace("Assets/StreamingAssets", "FPartPack/MainPack") + "/" + ResConfig.STREAMINGASSETSCONFIG; sd = FSaveHandle.Create(lastStremingPath, FFilePath.FP_Abs); if (sd == null) { Debug.LogError(lastStremingPath + "文件夹下,没有找到旧的配置文件" + ResConfig.STREAMINGASSETSCONFIG + "对比文件失败"); } else { //曾经变化文件 string changeFile = mainPack + "/" + ResConfig.FCACHEFILE; BundleManager.LegacyPackFile cfiles = new BundleManager.LegacyPackFile(); FSaveHandle cSave = FSaveHandle.Create(changeFile, FFilePath.FP_Abs); if (cSave != null) { cSave.FromObject(cfiles); } BundleManager.StreamConfig LastStreamConif = new BundleManager.StreamConfig(); sd.FromObject(LastStreamConif); if (NewStreamConif.versionId <= LastStreamConif.versionId) { Debug.LogError(ResConfig.STREAMINGASSETSCONFIG + ":新的配置文件versionId比旧配置文件要低,对比文件失败"); } else { //精简文件 for (int i = 0; i < NewStreamConif.fileDatas.Count; i++) { var newData = NewStreamConif.fileDatas[i]; string tempBundleName = newData.fileName; string newMd5 = NewStreamConif.GetMd5(tempBundleName); string lastMd5 = LastStreamConif.GetMd5(tempBundleName); if (cfiles.Files.ContainsKey(newData.fileName))//&& newData.path.Contains("fxlua")) { ScriptsTime.Debug("以前版本有变动的文件:" + newData.path + "==" + tempBundleName); } else if ((newMd5 != lastMd5 || lastMd5 == "")) //&& newData.path.Contains("fxlua")) { //文件有更新 ScriptsTime.Debug("产生新的文件:" + newData.path + "==" + tempBundleName); cfiles.Files[newData.fileName] = 0; string exten = FEPath.GetExtension(newData.fileName); if (exten == ResConfig.ASSETBUNDLESUFFIXES) { cfiles.Bundles[newData.fileName.Replace(ResConfig.FDESASSETBUNDLE + "/", "")] = 1; } } else { string spePath = newPath + "/" + newData.fileName; File.Delete(spePath); } } string cachefile = newPath + "/" + ResConfig.FDESASSETBUNDLE + "/" + ResConfig.FCACHEFILE; cSave = FSaveHandle.Create(cachefile, FFilePath.FP_Abs, FOpenType.OT_Write); cSave.PushObject(cfiles); cSave.Save(); File.Copy(cachefile, changeFile, true); //重新生成压缩文件 int versioin = firstStreamConfi.versionId; CreateConfig(newPath, firstStreamConfi, 1); string partversionFile = ""; if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS) { partversionFile = copyPath.Replace("Assets/StreamingAssets", "FPartPack/" + versioin + "/ios1"); } else { partversionFile = copyPath.Replace("Assets/StreamingAssets", "FPartPack/" + versioin + "/az1"); } MyEdior.DeletFile(partversionFile); MyEdior.CopyDirectory(newPath, partversionFile); var t = FSaveHandle.Create(partversionFile + "/version", FFilePath.FP_Abs, FOpenType.OT_Write | FOpenType.OT_Txt); string md5 = FCommonFunction.GetMD5HashFromFile(partversionFile + "/FAssetbundle.zip"); int type = EditorUserBuildSettings.activeBuildTarget != BuildTarget.iOS ? 0:1; t.SetContext("{\"version\":" + versioin.ToString() + ",\"md5\":\"" + md5 + ",\"type\":\"" + type.ToString() + "\"}"); t.Save(); File.Delete(partversionFile + "/FAssetbundle.zip.meta"); File.Delete(partversionFile + "/FStreamingAssets"); File.Delete(partversionFile + "/FStreamingAssets.meta"); playFile = partversionFile; } } } } MyEdior.DeletFile(newPath); AssetDatabase.Refresh(); if (playFile != "") { System.Diagnostics.Process.Start(playFile); Debug.Log(isMain ? "主包生成完成" : "分包生成完成"); } }