Skip to content

Commit

Permalink
1.3.110 1.#32 的优化,2.打包的AssetBundles复制到Assets外Bundles内,并且加上平台名进行区分,3.热…
Browse files Browse the repository at this point in the history
…更新打包地址也增加平台进行区分,4.开发工具进行了排序,5.添加HybridCLR的补充元数据,6.完善文档
  • Loading branch information
TippingGame committed Mar 5, 2025
1 parent 353b06f commit c80b079
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 90 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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模块异步加载后同时使用同步加载报错的问题
Expand Down
2 changes: 1 addition & 1 deletion Editor/AssetManager/ABBuildTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
3 changes: 1 addition & 2 deletions Editor/Build/BuildPkgTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
57 changes: 21 additions & 36 deletions Editor/F8Helper/F8Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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<string> aotDllList = new List<string>
// {
// "mscorlib.dll",
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ git clone https://github.com/TippingGame/F8Framework.git

4. 输入 <https://github.com/TippingGame/F8Framework.git>,请确认导入成功

更新版本号说明,如: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)
Expand Down Expand Up @@ -161,6 +163,8 @@ In the Unity Package Manager, add the F8Framework package using Git URL.

4. Input <https://github.com/TippingGame/F8Framework.git>, 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)
Expand Down
1 change: 0 additions & 1 deletion Runtime/Common/URLSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static string GetAssetBundlesFolder()

public static string GetAssetBundlesOutPath()
{
// return Application.dataPath + "/StreamingAssets/" + AssetBundlesName + "/" + GetPlatformName();
return Application.dataPath + "/../Bundles/" + AssetBundlesName + "/" + GetPlatformName();
}

Expand Down
1 change: 0 additions & 1 deletion Runtime/HotUpdateManager/HotUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class HotUpdateManager : ModuleSingleton<HotUpdateManager>, 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";
Expand Down
3 changes: 2 additions & 1 deletion Tests/HotUpdateManager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Unity F8 HotUpdate 热更新版本管理,负责打包,分包,热更新资
* 选择打包平台,输出路径,版本号,远程资产加载地址,启用热更新,全量打包,分包,空包。
![image](https://tippinggame-1257018413.cos.ap-guangzhou.myqcloud.com/TippingGame/HotUpdateManager/ui_20240317214323.png)
--------------------------

* 如需本地测试热更新,注意清理沙盒目录中的临时文件
--------------------------
### 如构建失败:请尝试使用Unity自带的Build一次后再尝试

--------------------------
Expand Down
3 changes: 2 additions & 1 deletion Tests/HotUpdateManager/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Unity F8 HotUpdate 热更新版本管理,负责打包,分包,热更新资
* 选择打包平台,输出路径,版本号,远程资产加载地址,启用热更新,全量打包,分包,空包。
![image](https://tippinggame-1257018413.cos.ap-guangzhou.myqcloud.com/TippingGame/HotUpdateManager/ui_20240317214323.png)
--------------------------

* 如需本地测试热更新,注意清理沙盒目录中的临时文件
--------------------------
### 如构建失败:请尝试使用Unity自带的Build一次后再尝试

--------------------------
Expand Down
95 changes: 72 additions & 23 deletions Tests/HybridCLR/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,73 @@

## 简介(希望自己点击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<string> aotDllList = new List<string>
// {
// "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.F8ExcelDataClassF8Framework.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;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using F8Framework.Core;
using HybridCLR;
using UnityEngine;

public class LoadDll : MonoBehaviour
Expand Down Expand Up @@ -71,6 +103,23 @@ public class LoadDll : MonoBehaviour
HotUpdate.StartHotUpdate(hotUpdateAssetUrl, () =>
{
LogF8.Log("完成");
// 先补充元数据(可选)
List<string> aotDllList = new List<string>
{
"mscorlib.dll",
"System.dll",
"System.Core.dll", // 如果使用了Linq,需要这个
// "Newtonsoft.Json.dll",
// "protobuf-net.dll",
};

foreach (var aotDllName in aotDllList)
{
byte[] dllBytes = AssetManager.Instance.Load<TextAsset>(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<TextAsset>("F8Framework.F8ExcelDataClass");
Expand Down
Loading

0 comments on commit c80b079

Please sign in to comment.