| | |
| | | PrebuildCommand.GenerateAll(); |
| | | // 输出到AssetBundles目录 |
| | | var outputPath = Application.dataPath.Replace("Assets", m_UserData.m_OutputPath); |
| | | outputPath = StringUtility.Contact(outputPath, "/daimazijie"); |
| | | outputPath = StringUtility.Contact(outputPath, "/logicbytes");
|
| | | if (Directory.Exists(outputPath)) |
| | | Directory.Delete(outputPath, true); |
| | | //复制新生成的AOT dll到指定路径 |
| | |
| | | } |
| | | // 输出到AssetBundles目录 |
| | | var outputPath = Application.dataPath.Replace("Assets", m_UserData.m_OutputPath); |
| | | outputPath = StringUtility.Contact(outputPath, "/daimazijie"); |
| | | outputPath = StringUtility.Contact(outputPath, "/logicbytes");
|
| | | CopyHotUpdateDll(outputPath); |
| | | MakeBytesVersionFile(); |
| | | AssetDatabase.Refresh(); |
| | |
| | | |
| | | private void MakeBytesVersionFile() |
| | | { |
| | | ChangeBytes();
|
| | | var fileInfos = new List<FileInfo>(); |
| | | FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(m_UserData.m_OutputPath, "/daimazijie"), fileInfos); |
| | | FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(m_UserData.m_OutputPath, "/logicbytes"), fileInfos);
|
| | | BytesVersionMaker.WriteAssetsVersionFile(Path.Combine(Directory.GetParent(Application.dataPath).FullName, m_UserData.m_OutputPath), fileInfos); |
| | | Debug.Log("热更新代码更新完毕,生成md5文件"); |
| | | } |
| | |
| | | for (int i = 0; i < AOTGenericReferences.PatchedAOTAssemblyList.Count; i++) |
| | | { |
| | | string dllFile = StringUtility.Contact(aotDir, AOTGenericReferences.PatchedAOTAssemblyList[i]); |
| | | var outDllFile = outputPath + "/" + AssetVersionUtility.EncodeFileName(AOTGenericReferences.PatchedAOTAssemblyList[i]) + ".bytes"; |
| | | var outDllFile = outputPath + "/" + AOTGenericReferences.PatchedAOTAssemblyList[i] + ".bytes";
|
| | | if (!File.Exists(dllFile)) |
| | | { |
| | | DebugEx.LogErrorFormat("错误:{0} 不存在", dllFile); |
| | |
| | | } |
| | | |
| | | FileExtersion.MakeSureDirectory(outDllFile); |
| | | //File.Copy(dllFile, outDllFile, true); |
| | | ChangeBytes(dllFile, outDllFile); |
| | | File.Copy(dllFile, outDllFile, true);
|
| | | } |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | FileExtersion.MakeSureDirectory(outDllFile); |
| | | //File.Copy(dllFile, outDllFile, true); |
| | | ChangeBytes(dllFile, outDllFile); |
| | | File.Copy(dllFile, outDllFile, true);
|
| | | } |
| | | |
| | | //HybridCLR的Settings面板上设置的要热更的DLL资源 |
| | |
| | | return; |
| | | } |
| | | FileExtersion.MakeSureDirectory(outDllFile); |
| | | //File.Copy(dllFile, outDllFile, true); |
| | | ChangeBytes(dllFile, outDllFile); |
| | | File.Copy(dllFile, outDllFile, true);
|
| | | } |
| | | |
| | | //HybridCLR的Settings面板上设置的预留的热更新dlls |
| | |
| | | continue; |
| | | } |
| | | FileExtersion.MakeSureDirectory(outDllFile); |
| | | //File.Copy(dllFile, outDllFile, true); |
| | | ChangeBytes(dllFile, outDllFile); |
| | | File.Copy(dllFile, outDllFile, true);
|
| | | } |
| | | } |
| | | |
| | |
| | | FileExtersion.GetAllDirectoryFileInfos(m_UserData.m_OutputPath, fileInfos); |
| | | AssetsVersionMaker.WriteAssetsVersionFile(Path.Combine(Directory.GetParent(Application.dataPath).FullName, m_UserData.m_OutputPath), fileInfos);
|
| | | |
| | | Debug.Log("AVersion.txt文件完毕"); |
| | | Debug.Log("生成AssetsVersion.txt文件完毕");
|
| | | } |
| | | |
| | | void ChangeBytes(string originalDllBytesFilePath, string outDllFile)
|
| | | void ChangeBytes()
|
| | | {
|
| | | string path = StringUtility.Contact(m_UserData.m_OutputPath, "/daimazijie/");
|
| | | string path = StringUtility.Contact(m_UserData.m_OutputPath, "/logicbytes/");
|
| | | // 原始DLL字节内容文件的路径 |
| | | string originalDllBytesFilePath = path + "Assembly-CSharp.dll.bytes";
|
| | |
|
| | | // 临时文件的路径,用于写入"abc"后再追加原始DLL字节内容
|
| | | string tempFilePath = AssetVersionUtility.EncodeFileName(outDllFile);
|
| | |
|
| | | // 如果目标文件存在,则删除它 |
| | | if (File.Exists(tempFilePath))
|
| | | {
|
| | | File.Delete(tempFilePath);
|
| | | }
|
| | | string tempFilePath = path + "temp_Assembly-CSharp.dll.bytes";
|
| | |
|
| | | // 要写入的字符串"abc"
|
| | | string contentToWrite = "cbg";
|
| | | string contentToWrite = "abc";
|
| | |
|
| | | // 将"abc"转换为字节数组
|
| | | byte[] abcBytes = Encoding.ASCII.GetBytes(contentToWrite);
|
| | |
| | | fs.Write(originalDllBytes, 0, originalDllBytes.Length);
|
| | | }
|
| | |
|
| | | ReplaceFile(tempFilePath, originalDllBytesFilePath);
|
| | | }
|
| | |
|
| | | public void ReplaceFile(string sourceFile, string targetFile)
|
| | | {
|
| | | // 确保源文件存在 |
| | | if (!File.Exists(sourceFile))
|
| | | {
|
| | | throw new FileNotFoundException("源文件未找到:" + sourceFile);
|
| | | }
|
| | |
|
| | | // 如果目标文件存在,则删除它 |
| | | if (File.Exists(targetFile))
|
| | | {
|
| | | File.Delete(targetFile);
|
| | | }
|
| | |
|
| | | // 将源文件重命名为目标文件 |
| | | File.Move(sourceFile, targetFile);
|
| | | }
|
| | |
|
| | | |
| | | static int packageIndex |
| | |
| | | using System;
|
| | | using UnityEngine;
|
| | | using LitJson;
|
| | | using System.Linq;
|
| | |
|
| | | public partial class #ClassName#
|
| | | {
|
| | |
| | | try
|
| | | {
|
| | | var line = lines[i];
|
| | | if (!AssetSource.refdataFromEditor)
|
| | | { |
| | | line = new string(line.Reverse().ToArray());
|
| | | }
|
| | | var index = line.IndexOf("\t");
|
| | | if (index == -1)
|
| | | {
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | bool isEditor = AssetSource.refdataFromEditor;
|
| | | ThreadPool.QueueUserWorkItem((object _object) =>
|
| | | {
|
| | | var lines = File.ReadAllLines(path);
|
| | |
| | | try
|
| | | {
|
| | | var line = lines[i];
|
| | | if (!isEditor)
|
| | | { |
| | | line = new string(line.Reverse().ToArray());
|
| | | }
|
| | | var index = line.IndexOf("\t");
|
| | | if (index == -1)
|
| | | {
|
| | |
| | | using UnityEngine;
|
| | | using UnityEditor;
|
| | | using System.IO;
|
| | | using System.Text;
|
| | | using System.Linq;
|
| | |
|
| | | public class AssetBundleBuildExtersion
|
| | | {
|
| | |
| | | for (int i = 0; i < targetAssetBundles.Count; i++)
|
| | | {
|
| | | var assetBundleBuild = new AssetBundleBuild();
|
| | |
|
| | | assetBundleBuild.assetBundleName = AssetVersionUtility.EncodeFileName(targetAssetBundles[i]);
|
| | | assetBundleBuild.assetBundleName = targetAssetBundles[i];
|
| | | assetBundleBuild.assetNames = AssetDatabase.GetAssetPathsFromAssetBundle(targetAssetBundles[i]);
|
| | | assets.Add(assetBundleBuild);
|
| | | }
|
| | |
|
| | | var rootPath = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, category);
|
| | | var mainFile = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, GetMainFestFileName(buildTarget));//改名字前
|
| | | var mainFileRename = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, AssetVersionUtility.EncodeFileName(category), "_abundle");//改名字后
|
| | | var mainFileRename = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, category, "_assetbundle");//改名字后
|
| | | var manifest = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, GetMainFestFileName(buildTarget), ".manifest");
|
| | | var manifestRename = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, AssetVersionUtility.EncodeFileName(category), "_abundle.manifest");
|
| | | var manifestRename = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, category, "_assetbundle.manifest");
|
| | |
|
| | | if (rebuild && Directory.Exists(rootPath))
|
| | | Directory.Delete(rootPath, true);
|
| | |
| | | for (int i = 0; i < _fileInfos.Count; i++)
|
| | | {
|
| | | var fileInfo = _fileInfos[i];
|
| | | if (fileInfo.Name == "AVersion.txt")
|
| | | if (fileInfo.Name == "AssetsVersion.txt")
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (fileInfo.Name == "AVersionCmp.txt")
|
| | | if (fileInfo.Name == "AssetsVersionCmp.txt")
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
| | | {
|
| | | continue;
|
| | | }
|
| | | if (fileInfo.FullName.Contains("daimazijie"))
|
| | | if (fileInfo.FullName.Contains("logicbytes"))
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
| | | lines.Add(StringUtility.Contact(relativePath, "\t", extersion, "\t", fileSize, "\t", md5));
|
| | | }
|
| | |
|
| | | var assetVersionFile = StringUtility.Contact(Application.dataPath, "/Resources/AVersionCmp.txt");
|
| | | var assetVersionFile = StringUtility.Contact(Application.dataPath, "/Resources/AssetsVersionCmp.txt");
|
| | | if (File.Exists(assetVersionFile))
|
| | | {
|
| | | File.Delete(assetVersionFile);
|
| | |
| | | for (int i = 0; i < _fileInfos.Count; i++)
|
| | | {
|
| | | var fileInfo = _fileInfos[i];
|
| | | if (fileInfo.Name == "AVersion.txt")
|
| | | if (fileInfo.Name == "AssetsVersion.txt")
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (fileInfo.Name == "AVersionCmp.txt")
|
| | | if (fileInfo.Name == "AssetsVersionCmp.txt")
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
| | | {
|
| | | continue;
|
| | | }
|
| | | if (fileInfo.FullName.Contains("daimazijie"))
|
| | | if (fileInfo.FullName.Contains("logicbytes"))
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
| | | lines.Add(StringUtility.Contact(relativePath, "\t", extersion, "\t", fileSize, "\t", md5));
|
| | | }
|
| | |
|
| | | var assetVersionFile = StringUtility.Contact(_path, Path.DirectorySeparatorChar, "AVersion.txt");
|
| | | var assetVersionFile = StringUtility.Contact(_path, Path.DirectorySeparatorChar, "AssetsVersion.txt");
|
| | | if (File.Exists(assetVersionFile))
|
| | | {
|
| | | File.Delete(assetVersionFile);
|
| | | }
|
| | |
|
| | | File.WriteAllText(StringUtility.Contact(_path, Path.DirectorySeparatorChar, "AVersion.txt"), string.Join(FileExtersion.lineSplit, lines.ToArray()));
|
| | | File.WriteAllText(StringUtility.Contact(_path, Path.DirectorySeparatorChar, "AssetsVersion.txt"), string.Join(FileExtersion.lineSplit, lines.ToArray()));
|
| | | } |
| | | |
| | | } |
| | |
| | | for (int i = 0; i < _fileInfos.Count; i++)
|
| | | {
|
| | | var fileInfo = _fileInfos[i];
|
| | | if (fileInfo.Name == "daimazijie.txt")
|
| | | if (fileInfo.Name == "logicbytes.txt")
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
| | | lines.Add(StringUtility.Contact(relativePath, "\t", extersion, "\t", fileSize, "\t", md5));
|
| | | }
|
| | |
|
| | | var assetVersionFile = StringUtility.Contact(_path, Path.DirectorySeparatorChar, "daimazijie.txt");
|
| | | var assetVersionFile = StringUtility.Contact(_path, Path.DirectorySeparatorChar, "logicbytes.txt");
|
| | | if (File.Exists(assetVersionFile))
|
| | | {
|
| | | File.Delete(assetVersionFile);
|
| | | }
|
| | |
|
| | | File.WriteAllText(StringUtility.Contact(_path, Path.DirectorySeparatorChar, "daimazijie.txt"), string.Join(FileExtersion.lineSplit, lines.ToArray()));
|
| | | File.WriteAllText(StringUtility.Contact(_path, Path.DirectorySeparatorChar, "logicbytes.txt"), string.Join(FileExtersion.lineSplit, lines.ToArray()));
|
| | | } |
| | | |
| | | } |
| | |
| | |
|
| | | public static string auditOutTime = string.Empty;
|
| | |
|
| | | public static string SDK_PLUGIN_PROJECT {
|
| | | public static string SDK_PLUGIN_PROJECT
|
| | | {
|
| | | get { return LocalSave.GetString("SDK_PROJECT_PATH"); }
|
| | | set { LocalSave.SetString("SDK_PROJECT_PATH", value); }
|
| | | }
|
| | |
|
| | | public static bool obfuscatorEnabled {
|
| | | public static bool obfuscatorEnabled
|
| | | {
|
| | | get { return LocalSave.GetBool("obfuscatorEnabled", false); }
|
| | | set { LocalSave.SetBool("obfuscatorEnabled", value); }
|
| | | }
|
| | | public static bool includeConfig {
|
| | | public static bool includeConfig
|
| | | {
|
| | | get { return LocalSave.GetBool("client_pg_includeConfig", false); }
|
| | | set { LocalSave.SetBool("client_pg_includeConfig", value); }
|
| | | }
|
| | |
|
| | | public static bool includeUI {
|
| | | public static bool includeUI
|
| | | {
|
| | | get { return LocalSave.GetBool("client_pg_includeUI", false); }
|
| | | set { LocalSave.SetBool("client_pg_includeUI", value); }
|
| | | }
|
| | |
|
| | | public static int AssetPrior {
|
| | | public static int AssetPrior
|
| | | {
|
| | | get { return LocalSave.GetInt("HalfAssetPrior", 1); }
|
| | | set { LocalSave.SetInt("HalfAssetPrior", value); }
|
| | | }
|
| | |
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Mob, AssetVersionUtility.DecodeFileName(fileName));
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Mob, fileName);
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | |
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Scene, AssetVersionUtility.DecodeFileName(fileName));
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Scene, fileName);
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | |
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Audio, AssetVersionUtility.DecodeFileName(fileName));
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Audio, fileName);
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | |
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Effect, AssetVersionUtility.DecodeFileName(fileName));
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Effect, fileName);
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | |
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Video, AssetVersionUtility.DecodeFileName(fileName));
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Video, fileName);
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | |
| | | //该文件在打包时生成 记录随包的所有资源的信息
|
| | | //该文件记录的资源在包中肯定存在,所以不用去取指定的资源文件获得FileInfo 计算MD5
|
| | | //通过文件和AssetsVersion.txt的文件做比较,来判断是否需要下载资源
|
| | | //daimazijie.txt 包含元数据和代码 如果不随包也要处理
|
| | | //logicbytes.txt 包含元数据和代码 如果不随包也要处理
|
| | | static void MakePackageMD5File()
|
| | | {
|
| | | var fileInfos = new List<FileInfo>();
|
| | | FileExtersion.GetAllDirectoryFileInfos(ResourcesPath.Instance.StreamingAssetPath, fileInfos);
|
| | | AssetsVersionCmpMaker.WriteAssetsVersionFile(ResourcesPath.Instance.StreamingAssetPath, fileInfos);
|
| | | Debug.Log("--生成AVersionCmp.txt文件完毕");
|
| | | Debug.Log("--生成AssetsVersionCmp.txt文件完毕");
|
| | | }
|
| | |
|
| | | private static void PreBuild(string _publisher, int _buildIndex)
|
| | |
| | | SetIconAndSplashImage(versionName);
|
| | | //SetCreateRoleAnimation();
|
| | |
|
| | | PlayerSettings.companyName = "desj";
|
| | | PlayerSettings.companyName = "SW";
|
| | | PlayerSettings.productName = newVersionConfig.productName;
|
| | | PlayerSettings.applicationIdentifier = newVersionConfig.bundleIdentifier;
|
| | | PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation;
|
| | |
| | | EditorGUILayout.Space();
|
| | | EditorGUILayout.Space();
|
| | | InGameDownTestUtility.isReadVesionEx = EditorGUILayout.Toggle("是否下载热更代码", InGameDownTestUtility.isReadVesionEx);
|
| | | EditorGUILayout.TextField("开启下载热更代码,会读取VersionConfigEx.txt 分支需配置正确, 检测daimazijie.txt");
|
| | | EditorGUILayout.TextField("开启下载热更代码,会读取VersionConfigEx.txt 分支需配置正确, 检测logicbytes.txt");
|
| | | }
|
| | |
|
| | | } |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Linq;
|
| | | using System.Text;
|
| | | using System.Windows.Forms;
|
| | | using UnityEditor;
|
| | |
| | | foreach (var file in configFiles)
|
| | | {
|
| | | var fileInfo = new FileInfo(file.FullName);
|
| | | CopyTxtBuild(fileInfo);
|
| | | CopyTxt(fileInfo);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | File.Copy(fileInfo.FullName, filePath);
|
| | | }
|
| | |
|
| | | private static void CopyTxtBuild(FileInfo fileInfo)
|
| | | {
|
| | | string fileName = fileInfo.Name.Split('.')[0];
|
| | |
|
| | | if (!Directory.Exists(configOutPutPath))
|
| | | {
|
| | | Directory.CreateDirectory(configOutPutPath);
|
| | | }
|
| | |
|
| | | string filePath = configOutPutPath + "/" + AssetVersionUtility.EncodeFileName(fileName) + ".txt";
|
| | | if (File.Exists(filePath))
|
| | | {
|
| | | File.Delete(filePath);
|
| | | }
|
| | |
|
| | | if (fileName.Contains("MapData_"))
|
| | | {
|
| | | File.Copy(fileInfo.FullName, filePath);
|
| | | }
|
| | | else
|
| | | {
|
| | | //按行读取文件,并将每行内容倒序写入新文件
|
| | | using (StreamReader sr = new StreamReader(fileInfo.FullName, Encoding.UTF8))
|
| | | {
|
| | | using (StreamWriter sw = new StreamWriter(filePath, false, Encoding.UTF8))
|
| | | {
|
| | | string line;
|
| | | while ((line = sr.ReadLine()) != null)
|
| | | {
|
| | | sw.WriteLine(new string(line.Reverse().ToArray()));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | {
|
| | | public class AssetVersion
|
| | | {
|
| | | //参考文本 daimazijie/Assembly-CSharp.dll.bytes .bytes 7360512 71157bfdecb53e8a580432621f3725c7
|
| | | //参考文本 logicbytes/Assembly-CSharp.dll.bytes .bytes 7360512 71157bfdecb53e8a580432621f3725c7
|
| | | string m_RelativePath = string.Empty;
|
| | | public string relativePath { get { return m_RelativePath; } }
|
| | |
|
| | |
| | | using System.IO;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using System.Linq;
|
| | |
|
| | |
|
| | | namespace StartAot
|
| | | {
|
| | |
| | | int lineIndex = 0;
|
| | | while ((line = reader.ReadLine()) != null)
|
| | | {
|
| | | #if !UNITY_EDITOR
|
| | | line = new string(line.Reverse().ToArray());
|
| | | #endif
|
| | | lineIndex++;
|
| | | if (lineIndex <= 3)
|
| | | {
|
| | |
| | |
|
| | | private string GetWebRequestPath(string asset)
|
| | | {
|
| | | var path = ResourcesModel.Instance.GetAssetFilePath(string.Concat(ResourcesModel.bytesFolderName, asset), false);
|
| | | var path = ResourcesModel.Instance.GetAssetFilePath(string.Concat(ResourcesModel.bytesFolderName, asset));
|
| | |
|
| | | if (!path.Contains("file:"))
|
| | | {
|
| | |
| | | {
|
| | | // 特殊处理
|
| | | byte[] assetData;
|
| | |
|
| | | if (asset == "Assembly-CSharp.dll.bytes")
|
| | | {
|
| | | assetData = new byte[www.downloadHandler.data.Length - 3];
|
| | | Array.Copy(www.downloadHandler.data, 3, assetData, 0, assetData.Length);
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | assetData = www.downloadHandler.data;
|
| | | }
|
| | |
|
| | | Debug.Log($"dll:{asset} size:{assetData.Length}");
|
| | | s_assetDatas[asset] = assetData;
|
| | |
| | | HomologousImageMode mode = HomologousImageMode.SuperSet;
|
| | | foreach (var aotDllName in AOTMetaAssemblyFiles)
|
| | | {
|
| | | if (aotDllName == ResourcesModel.Instance.EncodeFileName("Assembly-CSharp.dll.bytes"))
|
| | | if (aotDllName == "Assembly-CSharp.dll.bytes")
|
| | | continue;
|
| | | // 加载assembly对应的dll,会自动为它hook。一旦aot泛型函数的native函数不存在,用解释器版本代码
|
| | | LoadImageErrorCode err = RuntimeApi.LoadMetadataForAOTAssembly(ReadBytesFromStreamingAssets(aotDllName), mode);
|
| | |
| | | {
|
| | | #if !UNITY_EDITOR
|
| | | LoadMetadataForAOTAssemblies();
|
| | | _hotUpdateAss = Assembly.Load(ReadBytesFromStreamingAssets(ResourcesModel.Instance.EncodeFileName("Assembly-CSharp.dll.bytes")));
|
| | | _hotUpdateAss = Assembly.Load(ReadBytesFromStreamingAssets("Assembly-CSharp.dll.bytes"));
|
| | | s_assetDatas = null;
|
| | | #else
|
| | | if (_hotUpdateAss == null)
|
| | |
| | | using LitJsonForAot;
|
| | | using System.Collections;
|
| | | using UnityEngine.Networking;
|
| | | using System.Linq;
|
| | | using StartAotSDK;
|
| | |
|
| | |
|
| | | namespace StartAot
|
| | | {
|
| | |
| | | {
|
| | | //不下载时本地安卓测试路径
|
| | | public string assetBundlesPath { get; private set; }
|
| | | public static string bytesFolderName = "daimazijie/";
|
| | | public static string bytesFolderName = "logicbytes/";
|
| | | public string StreamingAssetPath { get; private set; }
|
| | | public string ExternalStorePath { get; private set; }
|
| | |
|
| | |
| | |
|
| | | public int debugBranch { get; private set; }
|
| | |
|
| | |
|
| | | public class DebugBranch
|
| | | {
|
| | | public int branch = -1;
|
| | | }
|
| | |
|
| | | private int urlIndex = 0;
|
| | | private string versionUrl;
|
| | |
| | | string assetBytesUrl;
|
| | | //从网络获取的资源版本信息
|
| | | public Dictionary<string, AssetVersion> assetVersions = new Dictionary<string, AssetVersion>();
|
| | | //本地daimazijie文件和 assetVersions 比较是否需要下载
|
| | | //本地LogicBytes文件和 assetVersions 比较是否需要下载
|
| | | public Dictionary<string, AssetVersion> localAssetVersions = new Dictionary<string, AssetVersion>();
|
| | | public static string versionUrlResult { get; private set; }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | //将文件名倒序,加上_aop后缀
|
| | | public string EncodeFileName(string name)
|
| | | public class VersionInfo
|
| | | {
|
| | | name = name.Replace("\\", "/");
|
| | | int index = name.LastIndexOf("/");
|
| | | string headString;
|
| | | if (index >= 0)
|
| | | public JsonData notice_flag;
|
| | | public JsonData resource_url; //这里只用到这个取下载地址
|
| | | public string ResourceAward;
|
| | | public int downAsset = 1;
|
| | | public string downUrl;
|
| | | public int VersionCount;
|
| | |
|
| | |
|
| | | public string GetResourcesURL(int _branch)
|
| | | {
|
| | | int dotLastIndex = name.LastIndexOf(".");
|
| | | if (dotLastIndex == -1)
|
| | | if (resource_url != null)
|
| | | {
|
| | | headString = name.Substring(0, index);
|
| | | name = name.Substring(index + 1);
|
| | | return StringUtility.Contact(headString, "/", new string(name.Reverse().ToArray()), "_aop");
|
| | | return resource_url[_branch.ToString()].ToString();
|
| | | }
|
| | | else
|
| | | {
|
| | | headString = name.Substring(0, index);
|
| | | var ext = name.Substring(dotLastIndex);
|
| | | name = name.Substring(index + 1, dotLastIndex - index - 1);
|
| | | return StringUtility.Contact(headString, "/", new string(name.Reverse().ToArray()), "_aop", ext);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | int dotLastIndex = name.LastIndexOf(".");
|
| | | if (dotLastIndex == -1)
|
| | | return StringUtility.Contact(new string(name.Reverse().ToArray()), "_aop");
|
| | | else
|
| | | {
|
| | | var ext = name.Substring(dotLastIndex);
|
| | | name = name.Substring(0, dotLastIndex);
|
| | | return StringUtility.Contact(new string(name.Reverse().ToArray()), "_aop", ext);
|
| | | return string.Empty;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | public string GetAssetFilePath(string _assetKey, bool reverse = true)
|
| | | public string GetAssetFilePath(string _assetKey)
|
| | | {
|
| | | if (reverse)
|
| | | _assetKey = EncodeFileName(_assetKey);
|
| | | var path = Path.Combine(ExternalStorePath, _assetKey);
|
| | | if (!File.Exists(path))
|
| | | {
|
| | |
| | | //LogicBytes文件的MD5信息
|
| | | public void RequestLogicBytes()
|
| | | {
|
| | | var remoteURL = string.Concat(versionInfo.GetResourcesURL(VersionConfigEx.Get().branch), fixPath, "/daimazijie.txt");
|
| | | var remoteURL = string.Concat(versionInfo.GetResourcesURL(VersionConfigEx.Get().branch), fixPath, "/logicbytes.txt");
|
| | | //var localURL = string.Concat(.ExternalStorePath, "/logicbytes.txt");
|
| | | assetBytesUrl = remoteURL;
|
| | | Debug.Log("http地址:logicbytesUrl " + assetBytesUrl);
|
| | |
| | | if (isPCTestDownLoad || Application.isMobilePlatform)
|
| | | {
|
| | | //读取的一定是StreamingAssetPath路径
|
| | | StartCoroutine(ReadText("daimazijie", (isOK, value) =>
|
| | | StartCoroutine(ReadText("logicbytes", (isOK, value) =>
|
| | | {
|
| | | if (isOK)
|
| | | InitLocalLogicbytes(value);
|
| | |
| | | Debug.LogError(ex);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | namespace StartAotSDK
|
| | | {
|
| | | public class DebugBranch
|
| | | {
|
| | | public int branch = -1;
|
| | | }
|
| | |
|
| | | public class VersionInfo
|
| | | {
|
| | | public JsonData notice_flag;
|
| | | public JsonData resource_url; //这里只用到这个取下载地址
|
| | | public string ResourceAward;
|
| | | public int downAsset = 1;
|
| | | public string downUrl;
|
| | | public int VersionCount;
|
| | |
|
| | |
|
| | | public string GetResourcesURL(int _branch)
|
| | | {
|
| | | if (resource_url != null)
|
| | | {
|
| | | return resource_url[_branch.ToString()].ToString();
|
| | | }
|
| | | else
|
| | | {
|
| | | return string.Empty;
|
| | | }
|
| | | }
|
| | |
|