public static void CreateFileMethod() { /* 定义局部变量 */ string abOutPath = string.Empty; //AssetBundle 的输出路径 string verifyFileOutPath = string.Empty; //校验文件的路径 List <string> fileList = new List <string>(); //存储所有合法文件的相对路径信息集合 /* 定义校验文件的输出路径*/ abOutPath = PathTools.GetABOutPath(); //verifyFileOutPath = abOutPath + "/ProjectVerifyFile.txt";//Original verifyFileOutPath = abOutPath + ABDefine.ProjectVerifyFile; //Debug.Log("verifyFileOutPath=" + verifyFileOutPath); /* 如果本项目已经有校验文件,则进行覆盖。*/ if (File.Exists(verifyFileOutPath)) { File.Delete(verifyFileOutPath); } /* 遍历当前文件夹(校验文件的输出路径),所有的文件,生成MD5编码。*/ ListFile(new DirectoryInfo(abOutPath), ref fileList); /* 把文件的名称与对应的MD5编码,写入校验文件。*/ WriteVerifyFile(verifyFileOutPath, abOutPath, fileList); }//CreateFileMethod_end
/// <summary> /// 生成打包资源 /// </summary> /// <param name="target"></param> public static void BuildResource(BuildTarget target) { //打包AB输出路径 string strABOutPathDIR = string.Empty; //获取"StreamingAssets"数值 strABOutPathDIR = PathTools.GetABOutPath(); if (Directory.Exists(strABOutPathDIR)) { Directory.Delete(strABOutPathDIR, true); } Directory.CreateDirectory(strABOutPathDIR); AssetDatabase.Refresh(); //判断生成输出目录文件夹 if (!Directory.Exists(strABOutPathDIR)) { Directory.CreateDirectory(strABOutPathDIR); } //打包生成 BuildPipeline.BuildAssetBundles(strABOutPathDIR, BuildAssetBundleOptions.None, target); HandleLuaFile(); BuildFileIndex(); AssetDatabase.Refresh(); }
/// <summary> /// 生成打包文件的md5码 /// </summary> static void BuildFileIndex() { string resPath = PathTools.GetABOutPath(); ///----------------------创建文件列表----------------------- string newFilePath = resPath + "/files.txt"; 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); for (int i = 0; i < files.Count; i++) { string file = files[i]; string ext = Path.GetExtension(file); if (file.EndsWith(".meta") || file.Contains(".DS_Store")) { continue; } string md5 = Util.md5file(file); string value = file.Replace(resPath + "/", string.Empty); sw.WriteLine(value + "|" + md5); } sw.Close(); fs.Close(); }
private byte[] CustomLoader(ref string fileName) { string luaPath = PathTools.GetABOutPath() + "/Lua"; if (m_luaFileDict.ContainsKey(fileName)) { return(m_luaFileDict[fileName]); } return(ProcessDir(new DirectoryInfo(luaPath), fileName)); }
public static void DeleteAllAB() { string deleteDir = PathTools.GetABOutPath(); if (!string.IsNullOrEmpty(deleteDir)) { Directory.Delete(deleteDir, true);//true表示可以删除非空目录 File.Delete(deleteDir + ".meta"); AssetDatabase.Refresh(); } }
/// <summary> /// 打包Lua脚本 /// </summary> public static void HandleLuaFile() { string luaPath = PathTools.GetABOutPath() + "/lua/"; //----------复制Lua文件---------------- if (!Directory.Exists(luaPath)) { Directory.CreateDirectory(luaPath); } string[] luaPaths = { AppDataPath + "/lua/", AppDataPath + "/LuaFramework/Tolua/Lua/" }; for (int i = 0; i < luaPaths.Length; i++) { paths.Clear(); files.Clear(); string luaDataPath = luaPaths[i].ToLower(); Recursive(luaDataPath); int n = 0; foreach (string f in files) { if (f.EndsWith(".meta") || f.EndsWith(".DS_Store")) { continue; } string newfile = f.Replace(luaDataPath, ""); string newpath = luaPath + newfile; string path = Path.GetDirectoryName(newpath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (File.Exists(newpath)) { File.Delete(newpath); } if (AppConst.LuaByteMode) { EncodeLuaFile(f, newpath); } else { File.Copy(f, newpath, true); } UpdateProgress(n++, files.Count, newpath); } } EditorUtility.ClearProgressBar(); AssetDatabase.Refresh(); }
public static void BuildAllABIOS() { //打包AB输出路径 string strABOutPathDIR = PathTools.GetABOutPath(); //判断生成输出目录文件夹 if (!Directory.Exists(strABOutPathDIR)) { Directory.CreateDirectory(strABOutPathDIR); } //打包生成 BuildPipeline.BuildAssetBundles(strABOutPathDIR, BuildAssetBundleOptions.None, BuildTarget.iOS); }
public static void DelAssetBundle() { //删除AB包输出目录 string strNeedDeleteDIR = string.Empty; strNeedDeleteDIR = PathTools.GetABOutPath(); if (!string.IsNullOrEmpty(strNeedDeleteDIR)) { //注意: 这里参数"true"表示可以删除非空目录 Directory.Delete(strNeedDeleteDIR, true); //去除删除警告 File.Delete(strNeedDeleteDIR + ".meta"); //刷新 AssetDatabase.Refresh(); } }
public static void BuildAllAB() { //打包AB输出路径 string strABOutPathDIR = string.Empty; //获取"StreamingAssets"数值 strABOutPathDIR = PathTools.GetABOutPath(); //Application.streamingAssetPath/Windows //判断生成输出目录文件夹 if (!Directory.Exists(strABOutPathDIR)) { Directory.CreateDirectory(strABOutPathDIR); } //打包生成 BuildPipeline.BuildAssetBundles(strABOutPathDIR, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64); }
/// <summary> /// 自定义调取lua文件内容 /// </summary> /// <param name="fileName">lua文件名称</param> /// <returns></returns> private byte[] customLoader(ref string fileName) { //获取lua所在目录 string luaPath = PathTools.GetABOutPath() + PathTools.LUA_DEPLOY_PATH; //缓存判断处理: 根据lua文件路径,获取lua的内容 if (_DicLuaFileArray.ContainsKey(fileName)) { //如果在缓存中可以查找成功,则直接返回结果。 return(_DicLuaFileArray[fileName]); } else { return(ProcessDIR(new DirectoryInfo(luaPath), fileName)); } }
void Awake() { //默认启用热更新 if (EnableSelf) { //PC平台的资源(包含AsserBundl)下载路径 _DownloadPath = PathTools.GetABOutPath(); //检测资源进行对比更新 StartCoroutine(CheckUpdate(_ServerURL)); } //不启用热更新 else { Debug.Log("### WARING: " + GetType() + "/Awake()/本脚本已经勾选禁用!, 停止从服务器下载更新服务,特此通知!"); //通知其他游戏主逻辑,开始运行 //BroadcastMessage("ReceiveInfoStartRuning", SendMessageOptions.DontRequireReceiver); BroadcastMessage(ABDefine.ReceiveInfoStartRuning, SendMessageOptions.DontRequireReceiver); } }
public static void CreatFileMethod() { //ab输出路径 string abOutPath = PathTools.GetABOutPath(); //校验文件路径 string verifyFile = abOutPath + "/" + HotFixTool.VerifyFileName; //存储所有合法文件的相对路径信息 List <string> fileList = new List <string>(); //如果有这个文件 先删除 if (File.Exists(verifyFile)) { File.Delete(verifyFile); } ListFiles(new DirectoryInfo(abOutPath), ref fileList); WriteVerifyFile(verifyFile, fileList, abOutPath); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }