From c80b07977ca5b14bb910c32b15fa61e0e8606ccb Mon Sep 17 00:00:00 2001 From: TippingGame Date: Thu, 6 Mar 2025 02:22:42 +0800 Subject: [PATCH] =?UTF-8?q?1.3.110=201.#32=20=E7=9A=84=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C2.=E6=89=93=E5=8C=85=E7=9A=84AssetBundles=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E5=88=B0Assets=E5=A4=96Bundles=E5=86=85=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E5=8A=A0=E4=B8=8A=E5=B9=B3=E5=8F=B0=E5=90=8D?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=8C=BA=E5=88=86=EF=BC=8C3.=E7=83=AD?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=89=93=E5=8C=85=E5=9C=B0=E5=9D=80=E4=B9=9F?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B9=B3=E5=8F=B0=E8=BF=9B=E8=A1=8C=E5=8C=BA?= =?UTF-8?q?=E5=88=86=EF=BC=8C4.=E5=BC=80=E5=8F=91=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=BA=86=E6=8E=92=E5=BA=8F=EF=BC=8C5.?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0HybridCLR=E7=9A=84=E8=A1=A5=E5=85=85=E5=85=83?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=EF=BC=8C6.=E5=AE=8C=E5=96=84=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 ++ Editor/AssetManager/ABBuildTool.cs | 2 +- Editor/Build/BuildPkgTool.cs | 3 +- Editor/F8Helper/F8Helper.cs | 57 +++++------- README.md | 4 + Runtime/Common/URLSetting.cs | 1 - Runtime/HotUpdateManager/HotUpdateManager.cs | 1 - Tests/HotUpdateManager/README.md | 3 +- Tests/HotUpdateManager/README_EN.md | 3 +- Tests/HybridCLR/README.md | 95 +++++++++++++++----- Tests/HybridCLR/README_EN.md | 95 +++++++++++++++----- package.json | 2 +- 12 files changed, 184 insertions(+), 90 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c15087c..5b753e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [1.3.110] - 2025-03-06 +1.#32 的优化 +2.打包的AssetBundles复制到Assets外Bundles内,并且加上平台名进行区分 +3.热更新打包地址也增加平台进行区分 +4.开发工具进行了排序 +5.添加HybridCLR的补充元数据 +6.完善文档 + ## [1.2.109] - 2025-03-04 1.修复Input模块监听按键Down失败的问题 2.修复Asset模块异步加载后同时使用同步加载报错的问题 diff --git a/Editor/AssetManager/ABBuildTool.cs b/Editor/AssetManager/ABBuildTool.cs index d17240e..193e01d 100644 --- a/Editor/AssetManager/ABBuildTool.cs +++ b/Editor/AssetManager/ABBuildTool.cs @@ -194,7 +194,7 @@ public static string SetAssetBundleName(string path) if (!AssetGetParentPath(ai.assetBundleName).Equals(AssetGetParentPath(bundleName))) { //打印出父路径 - Debug.LogError("资产名和ab包名不相等:"+ai.assetBundleName + " > " + bundleName); + Debug.LogError("资产名和ab包名不相等:" + ai.assetBundleName + " > " + bundleName); } DiscrepantAssetPathMapping["/" + ai.assetBundleName] = "/" + bundleName.ToLower(); } diff --git a/Editor/Build/BuildPkgTool.cs b/Editor/Build/BuildPkgTool.cs index 6b5ded0..4e09e06 100644 --- a/Editor/Build/BuildPkgTool.cs +++ b/Editor/Build/BuildPkgTool.cs @@ -653,8 +653,7 @@ public static void WriteGameVersion() string toVersion = F8EditorPrefs.GetString(_toVersionKey, ""); - // string assetRemoteAddress = F8EditorPrefs.GetString(_assetRemoteAddressKey, ""); - //http://192.168.11.69/sgyyweb/Remote//Windows //远程资源增加区分平台 + //http://192.168.11.69/sgyyweb/Remote/Windows // 远程资源增加区分平台 string assetRemoteAddress = F8EditorPrefs.GetString(_assetRemoteAddressKey, "") + "Remote/" + URLSetting.GetPlatformName(); bool enableHotUpdate = F8EditorPrefs.GetBool(_enableHotUpdateKey, false); diff --git a/Editor/F8Helper/F8Helper.cs b/Editor/F8Helper/F8Helper.cs index d8eef45..7bb2679 100644 --- a/Editor/F8Helper/F8Helper.cs +++ b/Editor/F8Helper/F8Helper.cs @@ -40,40 +40,25 @@ public static void ClearAssetBundlesName() { ABBuildTool.ClearAllAssetNames(); } - - [MenuItem("开发工具/1: F8Run _F8",false,200)] + + [MenuItem("开发工具/1: F8Run _F8", false, 200)] public static void F8Run() { LoadAllExcelData(); F8EditorPrefs.SetBool("compilationFinishedHotUpdateDll", true); F8EditorPrefs.SetBool("compilationFinishedBuildAB", true); } - - [MenuItem("开发工具/3: 生成并复制热更新Dll-F8",false,210)] + + [MenuItem("开发工具/3: 生成并复制热更新Dll-F8", false, 210)] public static void GenerateCopyHotUpdateDll() { // F8EditorPrefs.SetBool("compilationFinishedHotUpdateDll", false); // HybridCLR.Editor.Commands.PrebuildCommand.GenerateAll(); - - // string outpath = Application.dataPath + "/AssetBundles/Code"; - - // //临时目录空的话就创建 - // if (Directory.Exists(outpath)) - // { - // //删除临时目录下的所有文件 - // foreach (string filePath in Directory.GetFiles(outpath)) - // { - // File.Delete(filePath); - // } - // } - // else - // { - // //创建目录 - // Directory.CreateDirectory(outpath); - // } - - // FileTools.SafeClearDir(Application.dataPath + "/AssetBundles/Code"); - // FileTools.CheckDirAndCreateWhenNeeded(Application.dataPath + "/AssetBundles/Code"); + // + // string outpath = Application.dataPath + "/AssetBundles/Code/"; + // + // FileTools.SafeClearDir(outpath); + // FileTools.CheckDirAndCreateWhenNeeded(outpath); // foreach (var dll in HybridCLR.Editor.SettingsUtil.HotUpdateAssemblyNamesExcludePreserved) // 获取HybridCLR设置面板的dll名称 // { // var path = @@ -82,11 +67,11 @@ public static void GenerateCopyHotUpdateDll() // Debug.Log("dll:"+path); // FileTools.SafeCopyFile( // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings.activeBuildTarget) + "/" + dll + ".dll", - // Application.dataPath + "/AssetBundles/Code/" + dll + ".bytes"); + // outpath + dll + ".bytes"); // LogF8.LogAsset("生成并复制热更新dll:" + dll); // } - - // //补充元数据 + // + // // 补充元数据 // List aotDllList = new List // { // "mscorlib.dll", @@ -95,29 +80,29 @@ public static void GenerateCopyHotUpdateDll() // // "Newtonsoft.Json.dll", // // "protobuf-net.dll", // }; - + // // foreach (var aotDllName in aotDllList) // { // var mscorlibsouPath = // HybridCLR.Editor.SettingsUtil.GetAssembliesPostIl2CppStripDir(EditorUserBuildSettings // .activeBuildTarget) + "/" + aotDllName; - + // // FileTools.SafeCopyFile( // mscorlibsouPath, - // Application.dataPath + "/AssetBundles/Code/"+ aotDllName +"by.bytes"); - // LogF8.LogAsset("生成并复制源数据dll:"+aotDllName); + // outpath + aotDllName + "by.bytes"); + // LogF8.LogAsset("生成并复制源数据dll:" + aotDllName); // } - + // // AssetDatabase.Refresh(); } - - [MenuItem("开发工具/2: Excel导表-F8",false,205)] + + [MenuItem("开发工具/2: Excel导表-F8", false, 205)] public static void LoadAllExcelData() { ExcelDataTool.LoadAllExcelData(); } - - [MenuItem("开发工具/4: 打包AssetBundles目录资源-F8",false,215)] + + [MenuItem("开发工具/4: 打包AssetBundles目录资源-F8", false, 215)] public static void BuildAssetBundles() { F8EditorPrefs.SetBool("compilationFinishedBuildAB", false); diff --git a/README.md b/README.md index 8e9e09a..86a115a 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ git clone https://github.com/TippingGame/F8Framework.git 4. 输入 ,请确认导入成功 +更新版本号说明,如:1.0.0,第一位代表大版本,第二位代表框架的使用有修改,第三位代表修订版本。(注意:确保更新框架前工程没有报错,更新后点击F8即可) + ## 新手指南 * [游戏启动器:](https://github.com/TippingGame/F8Framework/blob/main/Launcher/GameLauncher.cs)游戏启动器示例(注意:使用框架前必须先启动框架)。[GameLauncher.cs](https://github.com/TippingGame/F8Framework/blob/main/Launcher/GameLauncher.cs) @@ -161,6 +163,8 @@ In the Unity Package Manager, add the F8Framework package using Git URL. 4. Input , Please confirm successful import +Explanation of the updated version number. For example, in 1.0.0, the first digit represents the major version, the second digit indicates that there are modifications to the use of the framework, and the third digit represents the revision version. (Note: Make sure there are no errors in the project before updating the framework. After the update, simply click F8.) + ## GUIDE * [GameLauncher:](https://github.com/TippingGame/F8Framework/blob/main/Launcher/GameLauncher.cs)Game Launcher Example.[GameLauncher.cs](https://github.com/TippingGame/F8Framework/blob/main/Launcher/GameLauncher.cs) diff --git a/Runtime/Common/URLSetting.cs b/Runtime/Common/URLSetting.cs index 70d9fb7..4fd412d 100644 --- a/Runtime/Common/URLSetting.cs +++ b/Runtime/Common/URLSetting.cs @@ -17,7 +17,6 @@ public static string GetAssetBundlesFolder() public static string GetAssetBundlesOutPath() { - // return Application.dataPath + "/StreamingAssets/" + AssetBundlesName + "/" + GetPlatformName(); return Application.dataPath + "/../Bundles/" + AssetBundlesName + "/" + GetPlatformName(); } diff --git a/Runtime/HotUpdateManager/HotUpdateManager.cs b/Runtime/HotUpdateManager/HotUpdateManager.cs index 99267d7..fc2ae8d 100644 --- a/Runtime/HotUpdateManager/HotUpdateManager.cs +++ b/Runtime/HotUpdateManager/HotUpdateManager.cs @@ -13,7 +13,6 @@ public class HotUpdateManager : ModuleSingleton, IModule { public static string Separator = "_"; public static string PackageSplit = "Package" + Separator; - // public static string RemoteDirName = "/Remote"; public static string RemoteDirName = "/Remote/" + URLSetting.GetPlatformName(); public static string HotUpdateDirName = "/HotUpdate"; public static string PackageDirName = "/Package"; diff --git a/Tests/HotUpdateManager/README.md b/Tests/HotUpdateManager/README.md index 1c82d24..32a3877 100644 --- a/Tests/HotUpdateManager/README.md +++ b/Tests/HotUpdateManager/README.md @@ -20,7 +20,8 @@ Unity F8 HotUpdate 热更新版本管理,负责打包,分包,热更新资 * 选择打包平台,输出路径,版本号,远程资产加载地址,启用热更新,全量打包,分包,空包。 ![image](https://tippinggame-1257018413.cos.ap-guangzhou.myqcloud.com/TippingGame/HotUpdateManager/ui_20240317214323.png) -------------------------- - +* 如需本地测试热更新,注意清理沙盒目录中的临时文件 +-------------------------- ### 如构建失败:请尝试使用Unity自带的Build一次后再尝试 -------------------------- diff --git a/Tests/HotUpdateManager/README_EN.md b/Tests/HotUpdateManager/README_EN.md index 897bf82..f1521e6 100644 --- a/Tests/HotUpdateManager/README_EN.md +++ b/Tests/HotUpdateManager/README_EN.md @@ -20,7 +20,8 @@ Unity F8 HotUpdate 热更新版本管理,负责打包,分包,热更新资 * 选择打包平台,输出路径,版本号,远程资产加载地址,启用热更新,全量打包,分包,空包。 ![image](https://tippinggame-1257018413.cos.ap-guangzhou.myqcloud.com/TippingGame/HotUpdateManager/ui_20240317214323.png) -------------------------- - +* 如需本地测试热更新,注意清理沙盒目录中的临时文件 +-------------------------- ### 如构建失败:请尝试使用Unity自带的Build一次后再尝试 -------------------------- diff --git a/Tests/HybridCLR/README.md b/Tests/HybridCLR/README.md index 2eab01d..e000df7 100644 --- a/Tests/HybridCLR/README.md +++ b/Tests/HybridCLR/README.md @@ -6,34 +6,65 @@ ## 简介(希望自己点击F8,就能开始制作游戏,不想多余的事) 接入HybridCLR热更新代码组件。 -1. 使用这个[官方教程](https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart)创建HotUpdate程序集后。 -2. 找到代码[F8Helper.cs](https://github.com/TippingGame/F8Framework/blob/main/Editor/F8Helper/F8Helper.cs) - * 解除注释状态 +1. 使用这个[ 官方教程(快速上手) ](https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart)创建HotUpdate程序集后。 +2. 找到代码[ F8Helper.cs ](https://github.com/TippingGame/F8Framework/blob/main/Editor/F8Helper/F8Helper.cs) + * 解除注释状态,如下代码 +3. 补充元数据(可选项),具体看[ 官方教程(使用泛型) ](https://hybridclr.doc.code-philosophy.com/docs/beginner/generic) ```C# - [MenuItem("开发工具/生成并复制热更新Dll-F8")] - public static void GenerateCopyHotUpdateDll() - { - // F8EditorPrefs.SetBool("compilationFinishedHotUpdateDll", false); - // HybridCLR.Editor.Commands.PrebuildCommand.GenerateAll(); - // FileTools.SafeClearDir(Application.dataPath + "/AssetBundles/Code"); - // FileTools.CheckDirAndCreateWhenNeeded(Application.dataPath + "/AssetBundles/Code"); - // foreach (var dll in HybridCLR.Editor.SettingsUtil.HotUpdateAssemblyNamesExcludePreserved) // 获取HybridCLR设置面板的dll名称 - // { - // FileTools.SafeCopyFile( - // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings.activeBuildTarget) + "/" + dll + ".dll", - // Application.dataPath + "/AssetBundles/Code/" + dll + ".bytes"); - // LogF8.LogAsset("生成并复制热更新dll:" + dll); - // } - // AssetDatabase.Refresh(); - } +[MenuItem("开发工具/3: 生成并复制热更新Dll-F8",false,210)] +public static void GenerateCopyHotUpdateDll() +{ + // F8EditorPrefs.SetBool("compilationFinishedHotUpdateDll", false); + // HybridCLR.Editor.Commands.PrebuildCommand.GenerateAll(); + // + // string outpath = Application.dataPath + "/AssetBundles/Code/"; + // + // FileTools.SafeClearDir(outpath); + // FileTools.CheckDirAndCreateWhenNeeded(outpath); + // foreach (var dll in HybridCLR.Editor.SettingsUtil.HotUpdateAssemblyNamesExcludePreserved) // 获取HybridCLR设置面板的dll名称 + // { + // var path = + // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings + // .activeBuildTarget) + "/" + dll + ".dll"; + // Debug.Log("dll:"+path); + // FileTools.SafeCopyFile( + // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings.activeBuildTarget) + "/" + dll + ".dll", + // outpath + dll + ".bytes"); + // LogF8.LogAsset("生成并复制热更新dll:" + dll); + // } + // + // // 补充元数据 + // List aotDllList = new List + // { + // "mscorlib.dll", + // "System.dll", + // "System.Core.dll", // 如果使用了Linq,需要这个 + // // "Newtonsoft.Json.dll", + // // "protobuf-net.dll", + // }; + // + // foreach (var aotDllName in aotDllList) + // { + // var mscorlibsouPath = + // HybridCLR.Editor.SettingsUtil.GetAssembliesPostIl2CppStripDir(EditorUserBuildSettings + // .activeBuildTarget) + "/" + aotDllName; + // + // FileTools.SafeCopyFile( + // mscorlibsouPath, + // outpath + aotDllName + "by.bytes"); + // LogF8.LogAsset("生成并复制源数据dll:" + aotDllName); + // } + // + // AssetDatabase.Refresh(); +} ``` -3. 代码已拆分程序集 - * AOT程序集:(F8Framework.Core) - * 热更新程序集:(F8Framework.F8ExcelDataClass、F8Framework.Launcher) +3. 代码已拆分程序集(注意:AOT代码不能引用热更代码) + * AOT程序集:(F8Framework.Core)、(注意:散落在工程中的其他代码也会当作AOT打包) + * 热更新程序集:(F8Framework.F8ExcelDataClass)、(F8Framework.Launcher) 4. 将这两个热更新程序集拖进 HybridCLR 设置面板中 ![image](https://tippinggame-1257018413.cos.ap-guangzhou.myqcloud.com/TippingGame/HybridCLR/ui_20241128235509.png) 5. 注意:主工程不能直接引用热更新代码,这里通过反射来调用热更新代码。 - * 在启动场景挂在一个加载dll脚本 + * 在启动场景挂在一个加载dll脚本,先补充元数据(可选),加载热更新程序集 ```C# using System; using System.Collections; @@ -41,6 +72,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using F8Framework.Core; +using HybridCLR; using UnityEngine; public class LoadDll : MonoBehaviour @@ -71,6 +103,23 @@ public class LoadDll : MonoBehaviour HotUpdate.StartHotUpdate(hotUpdateAssetUrl, () => { LogF8.Log("完成"); + // 先补充元数据(可选) + List aotDllList = new List + { + "mscorlib.dll", + "System.dll", + "System.Core.dll", // 如果使用了Linq,需要这个 + // "Newtonsoft.Json.dll", + // "protobuf-net.dll", + }; + + foreach (var aotDllName in aotDllList) + { + byte[] dllBytes = AssetManager.Instance.Load(aotDllName + "by").bytes; + LoadImageErrorCode err = HybridCLR.RuntimeApi.LoadMetadataForAOTAssembly(dllBytes, HomologousImageMode.SuperSet); + LogF8.Log($"LoadMetadataForAOTAssembly:{aotDllName}. ret:{err}"); + } + // Editor环境下,HotUpdate.dll.bytes已经被自动加载,不需要加载,重复加载反而会出问题。 #if !UNITY_EDITOR TextAsset asset1 = AssetManager.Instance.Load("F8Framework.F8ExcelDataClass"); diff --git a/Tests/HybridCLR/README_EN.md b/Tests/HybridCLR/README_EN.md index ce7c722..b4a1620 100644 --- a/Tests/HybridCLR/README_EN.md +++ b/Tests/HybridCLR/README_EN.md @@ -6,34 +6,65 @@ ## 简介(希望自己点击F8,就能开始制作游戏,不想多余的事) 接入HybridCLR热更新代码组件。 -1. 使用这个[官方教程](https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart)创建HotUpdate程序集后。 -2. 找到代码[F8Helper.cs](https://github.com/TippingGame/F8Framework/blob/main/Editor/F8Helper/F8Helper.cs) - * 解除注释状态 +1. 使用这个[ 官方教程(快速上手) ](https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart)创建HotUpdate程序集后。 +2. 找到代码[ F8Helper.cs ](https://github.com/TippingGame/F8Framework/blob/main/Editor/F8Helper/F8Helper.cs) + * 解除注释状态,如下代码 +3. 补充元数据(可选项),具体看[ 官方教程(使用泛型) ](https://hybridclr.doc.code-philosophy.com/docs/beginner/generic) ```C# - [MenuItem("开发工具/生成并复制热更新Dll-F8")] - public static void GenerateCopyHotUpdateDll() - { - // F8EditorPrefs.SetBool("compilationFinishedHotUpdateDll", false); - // HybridCLR.Editor.Commands.PrebuildCommand.GenerateAll(); - // FileTools.SafeClearDir(Application.dataPath + "/AssetBundles/Code"); - // FileTools.CheckDirAndCreateWhenNeeded(Application.dataPath + "/AssetBundles/Code"); - // foreach (var dll in HybridCLR.Editor.SettingsUtil.HotUpdateAssemblyNamesExcludePreserved) // 获取HybridCLR设置面板的dll名称 - // { - // FileTools.SafeCopyFile( - // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings.activeBuildTarget) + "/" + dll + ".dll", - // Application.dataPath + "/AssetBundles/Code/" + dll + ".bytes"); - // LogF8.LogAsset("生成并复制热更新dll:" + dll); - // } - // AssetDatabase.Refresh(); - } +[MenuItem("开发工具/3: 生成并复制热更新Dll-F8",false,210)] +public static void GenerateCopyHotUpdateDll() +{ + // F8EditorPrefs.SetBool("compilationFinishedHotUpdateDll", false); + // HybridCLR.Editor.Commands.PrebuildCommand.GenerateAll(); + // + // string outpath = Application.dataPath + "/AssetBundles/Code/"; + // + // FileTools.SafeClearDir(outpath); + // FileTools.CheckDirAndCreateWhenNeeded(outpath); + // foreach (var dll in HybridCLR.Editor.SettingsUtil.HotUpdateAssemblyNamesExcludePreserved) // 获取HybridCLR设置面板的dll名称 + // { + // var path = + // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings + // .activeBuildTarget) + "/" + dll + ".dll"; + // Debug.Log("dll:"+path); + // FileTools.SafeCopyFile( + // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings.activeBuildTarget) + "/" + dll + ".dll", + // outpath + dll + ".bytes"); + // LogF8.LogAsset("生成并复制热更新dll:" + dll); + // } + // + // // 补充元数据 + // List aotDllList = new List + // { + // "mscorlib.dll", + // "System.dll", + // "System.Core.dll", // 如果使用了Linq,需要这个 + // // "Newtonsoft.Json.dll", + // // "protobuf-net.dll", + // }; + // + // foreach (var aotDllName in aotDllList) + // { + // var mscorlibsouPath = + // HybridCLR.Editor.SettingsUtil.GetAssembliesPostIl2CppStripDir(EditorUserBuildSettings + // .activeBuildTarget) + "/" + aotDllName; + // + // FileTools.SafeCopyFile( + // mscorlibsouPath, + // outpath + aotDllName + "by.bytes"); + // LogF8.LogAsset("生成并复制源数据dll:" + aotDllName); + // } + // + // AssetDatabase.Refresh(); +} ``` -3. 代码已拆分程序集 - * AOT程序集:(F8Framework.Core) - * 热更新程序集:(F8Framework.F8ExcelDataClass、F8Framework.Launcher) +3. 代码已拆分程序集(注意:AOT代码不能引用热更代码) + * AOT程序集:(F8Framework.Core)、(注意:散落在工程中的其他代码也会当作AOT打包) + * 热更新程序集:(F8Framework.F8ExcelDataClass)、(F8Framework.Launcher) 4. 将这两个热更新程序集拖进 HybridCLR 设置面板中 ![image](https://tippinggame-1257018413.cos.ap-guangzhou.myqcloud.com/TippingGame/HybridCLR/ui_20241128235509.png) 5. 注意:主工程不能直接引用热更新代码,这里通过反射来调用热更新代码。 - * 在启动场景挂在一个加载dll脚本 + * 在启动场景挂在一个加载dll脚本,先补充元数据(可选),加载热更新程序集 ```C# using System; using System.Collections; @@ -41,6 +72,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using F8Framework.Core; +using HybridCLR; using UnityEngine; public class LoadDll : MonoBehaviour @@ -71,6 +103,23 @@ public class LoadDll : MonoBehaviour HotUpdate.StartHotUpdate(hotUpdateAssetUrl, () => { LogF8.Log("完成"); + // 先补充元数据(可选) + List aotDllList = new List + { + "mscorlib.dll", + "System.dll", + "System.Core.dll", // 如果使用了Linq,需要这个 + // "Newtonsoft.Json.dll", + // "protobuf-net.dll", + }; + + foreach (var aotDllName in aotDllList) + { + byte[] dllBytes = AssetManager.Instance.Load(aotDllName + "by").bytes; + LoadImageErrorCode err = HybridCLR.RuntimeApi.LoadMetadataForAOTAssembly(dllBytes, HomologousImageMode.SuperSet); + LogF8.Log($"LoadMetadataForAOTAssembly:{aotDllName}. ret:{err}"); + } + // Editor环境下,HotUpdate.dll.bytes已经被自动加载,不需要加载,重复加载反而会出问题。 #if !UNITY_EDITOR TextAsset asset1 = AssetManager.Instance.Load("F8Framework.F8ExcelDataClass"); diff --git a/package.json b/package.json index 0877319..9841334 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.tippinggame.f8framework", "displayName": "F8Framework", "description": "Unity F8Framework Core", - "version": "1.2.109", + "version": "1.3.110", "unity": "2021.3", "license": "MIT", "keywords": ["Unity", "Framework", "Core"],