/* * 自动生成热更内容,即UpdateTest.txt文件 * */ public static void GenerateVersionContent() { var version = "3.1.3"; var content = ""; var fileContent = ""; var fileSize = 0; UpdateModuleMessage module = null; GenerateAssetBundleVersionContent(out module); fileContent += module.Content; fileSize += module.Size; module = null; LuaScriptEditor.GenerateScriptVersionContent(out module); fileContent += module.Content; fileSize += module.Size; module = null; ConfigEditor.GenerateConfigVersionContent(out module); fileContent += module.Content; fileSize += module.Size; content += "return {\n"; content += "\tVersion = \"" + version + "\",\n"; content += "\tUpdateURL = " + "\"" + UpdateManager.UpdateTest + "\",\n"; content += "\tUpdateSize = " + fileSize + ",\n"; content += fileContent; content += "}\n"; FileManager.CreateFileWithString(UpdateManager.UpdateTest + "/" + "UpdateTest.txt", content); }
public static void GenerateScriptVersionContent(out UpdateModuleMessage assetBundle) { assetBundle = new UpdateModuleMessage(); int assetSize = 0; string generate = "\tScripts = {\n"; List <string> fileList = new List <string>(); GetAllScriptFile(Application.dataPath + "/Resources" + SCRIPT_PATH, fileList); for (int i = 0; i < fileList.Count; ++i) { //TODO:加密每一个script文件,并拷贝到PersistentDataPath var file = fileList[i]; byte[] fileContent = null; FileManager.LoadFileWithBytes(file, out fileContent); var size = FileManager.GetFileSize(FileSizeUnitType.Type_Kb, fileContent.Length); generate += "\t\t{\n"; generate += "\t\t\tname=\"" + file.Replace(Application.dataPath + "/Resources/", "") + "\"" + ",\n"; generate += "\t\t\tsize=" + Mathf.Ceil(size) + ",\n"; generate += "\t\t},\n"; assetSize += (int)Mathf.Ceil(size); } generate += "\t},\n"; assetBundle.Content = generate; assetBundle.Size = assetSize; }
public static void GenerateScriptVersionContent(out UpdateModuleMessage assetBundle) { assetBundle = new UpdateModuleMessage(); int assetSize = 0; string generate = "\tScripts = {\n"; List<string> fileList = new List<string>(); GetAllScriptFile(Application.dataPath + "/Resources" + SCRIPT_PATH, fileList); for (int i = 0; i < fileList.Count; ++i) { //TODO:加密每一个script文件,并拷贝到PersistentDataPath var file = fileList[i]; byte[] fileContent = null; FileManager.LoadFileWithBytes(file, out fileContent); var size = FileManager.GetFileSize(FileSizeUnitType.Type_Kb, fileContent.Length); generate += "\t\t{\n"; generate += "\t\t\tname=\"" + file.Replace(Application.dataPath + "/Resources/", "") + "\"" + ",\n"; generate += "\t\t\tsize=" + Mathf.Ceil(size) + ",\n"; generate += "\t\t},\n"; assetSize += (int)Mathf.Ceil(size); } generate += "\t},\n"; assetBundle.Content = generate; assetBundle.Size = assetSize; }
static void GenerateAssetBundleVersionContent(out UpdateModuleMessage assetModule) { assetModule = new UpdateModuleMessage(); InitAssetBundleDict(); string content = ""; int moduleSize = 0; content += "\tPrefabs = {\n"; foreach (KeyValuePair <string, AssetBundleRequest> obj in _assetBundleDict) { var fullPath = UpdateManager.UpdateTest + "/" + obj.Key; content += "\t\t{\n"; content += "\t\t\tname=\"" + obj.Key + "\",\n"; var asset = new FileInfo(fullPath); content += "\t\t\tsize=" + Mathf.Ceil(FileManager.GetFileSize(FileSizeUnitType.Type_Kb, asset.Length)) + ",\n"; content += "\t\t},\n"; moduleSize += (int)Mathf.Ceil(FileManager.GetFileSize(FileSizeUnitType.Type_Kb, asset.Length)); } content += "\t},\n"; assetModule.Content = content; assetModule.Size = moduleSize; }
static void GenerateAssetBundleVersionContent(out UpdateModuleMessage assetModule) { assetModule = new UpdateModuleMessage(); InitAssetBundleDict(); string content = ""; int moduleSize = 0; content += "\tPrefabs = {\n"; foreach (KeyValuePair<string, AssetBundleRequest> obj in _assetBundleDict) { var fullPath = UpdateManager.UpdateTest + "/" + obj.Key; content += "\t\t{\n"; content += "\t\t\tname=\"" + obj.Key + "\",\n"; var asset = new FileInfo(fullPath); content += "\t\t\tsize=" + Mathf.Ceil(FileManager.GetFileSize(FileSizeUnitType.Type_Kb, asset.Length)) + ",\n"; content += "\t\t},\n"; moduleSize += (int)Mathf.Ceil(FileManager.GetFileSize(FileSizeUnitType.Type_Kb, asset.Length)); } content += "\t},\n"; assetModule.Content = content; assetModule.Size = moduleSize; }