Compare commits

...

120 Commits

Author SHA1 Message Date
ALEXTANG
7914660f8c Update SingletonSystem.cs 2024-05-24 14:00:51 +08:00
ALEXTANG
b00679a276 Merge pull request #75 from SunXuebing/main
调整编辑器模式下模块销毁顺序,解决编辑器退出运行后资源管理器销毁了还被调用问题
2024-05-20 14:17:40 +08:00
sxb
cd9a10ccac Update RootModule.cs
修复条件判断
2024-05-20 13:31:57 +08:00
sxb1067
f11098d32e 调整编辑器模式下模块销毁顺序,解决编辑器退出运行后资源管理器销毁了还被调用问题 2024-05-20 11:25:01 +08:00
ALEXTANGXIAO
db6e715fa6 Update ActorEventDispatcher.cs 2024-05-19 22:03:53 +08:00
ALEXTANG
c2edf71ee4 Update AssetItemObject.cs 2024-05-17 17:55:53 +08:00
ALEXTANG
75af7c22c7 Merge pull request #73 from Senfee-Cheng/main
[fix] 移除 `BuildDLLCommand` 构造函数以尝试解决hotfix dll数组被清除的问题
2024-05-17 15:48:27 +08:00
chengshengfei
2f9edf83bf Merge branch 'main' of github.com:Senfee-Cheng/TEngine 2024-05-17 15:45:26 +08:00
chengshengfei
815095efaf [fix] 移除 BuildDLLCommand 构造函数以尝试解决数组被清除的问题 2024-05-17 15:45:06 +08:00
ALEXTANG
3101a64a48 Merge pull request #72 from Severn17/main
yooasset 微信小游戏设置,详情看yooasset微信小游戏支持解决方案文档
2024-05-16 16:05:41 +08:00
yangshiqi
457e0f36a4 yooasset 微信小游戏设置,详情看yooasset微信小游戏支持解决方案文档 2024-05-16 15:19:32 +08:00
ALEXTANG
0bd30def23 移除示例package文件 2024-05-16 13:16:25 +08:00
ALEXTANG
d24db83c8b Update 99-各平台运行RunAble.md 2024-05-16 12:34:55 +08:00
ALEXTANG
18a2840777 Merge pull request #70 from Senfee-Cheng/main
[Platform] Supports console
2024-05-16 10:26:13 +08:00
chengshengfei
1d901514e1 新的平台支持[Sony Console] 2024-05-16 10:18:03 +08:00
chengshengfei
983279c56d 更新文档,添加新增的支持的平台。 2024-05-16 10:14:22 +08:00
ALEXTANG
e9540c620a Merge pull request #69 from Severn17/main
修改编辑器下webgl  平台名字 宏问题
2024-05-14 17:57:38 +08:00
yangshiqi
39be280d88 修改编辑器下webgl 平台名字 宏问题 2024-05-14 17:45:40 +08:00
ALEXTANG
f9f9122027 单例系统完善生命周期、支持Dispose 2024-05-13 14:09:32 +08:00
ALEXTANG
682a0bd786 Update UnityExtension.cs 2024-05-08 17:11:39 +08:00
ALEXTANG
34c514cae8 Update README.md 2024-05-08 10:31:41 +08:00
ALEXTANG
c707cc1a38 GameApp Shutdown 2024-05-08 10:06:33 +08:00
ALEXTANG
f016fdd0a6 Update ReleaseTools.cs 2024-05-07 20:09:15 +08:00
ALEXTANG
4c0f5a77f9 支持编辑器下EnterPlayMode Options 2024-05-07 18:05:41 +08:00
ALEXTANG
ae0d00424f Update ProfilerDefineSymbols.cs 2024-04-30 17:42:36 +08:00
ALEXTANG
c8ecac5815 Update README.md 2024-04-29 12:27:40 +08:00
ALEXTANG
4f8c1cdfdd 修正SpritePostprocessor处理Atlas的override 2024-04-25 15:43:44 +08:00
ALEXTANG
dff043e075 Update SahderVariantCollect
Update SahderVariantCollect
2024-04-24 11:17:38 +08:00
ALEXTANG
e69dc47b8f 修正编辑器调用转表bat 当前路径的问题
修正编辑器调用转表bat 当前路径的问题
2024-04-17 14:27:28 +08:00
ALEXTANG
fc2ef0714c 设置DefaultYooFolderName为package。原本设置默认为yoo。
设置DefaultYooFolderName为package。原本设置默认为yoo。
2024-04-15 19:58:57 +08:00
ALEXTANG
d75c1c8c93 升级YooAsset->2.1.1、UniTask->2.5.4
升级YooAsset->2.1.1、UniTask->2.5.4
2024-04-15 19:37:42 +08:00
ALEXTANG
83bea559e4 Merge pull request #65 from Senfee-Cheng/main 2024-04-12 18:19:10 +08:00
ALEXTANG
26689639ed Merge pull request #64 from ZemelLing/dev-launcher 2024-04-12 18:17:06 +08:00
chengshengfei
bd6ac5f4da 优化代码。 2024-04-12 10:58:06 +08:00
ZemelLing
70dcb03a3f 确保Launcher打开的main场景,而不是其他名称里包含main的场景。 2024-04-11 13:09:16 +08:00
ALEXTANG
59b3649155 优化框架轮询逻辑 ,用脏数据构建Execute数组。
优化框架轮询逻辑 ,用脏数据构建Execute数组。
2024-04-08 15:37:06 +08:00
ALEXTANG
2c025efe3b 修正预加载流程 2024-04-08 14:41:16 +08:00
ALEXTANG
7ae6ef94ba 修正同时对一个图片进行异步SetSprite的处理
修正同时对一个图片进行异步SetSprite的处理
2024-04-07 15:45:32 +08:00
ALEXTANG
d5bb64b314 资源异步加载从缓存中延迟分帧处理。 2024-04-07 15:33:45 +08:00
ALEXTANG
4c34858ce0 Update SettingsUtils.cs 2024-03-29 15:24:02 +08:00
ALEXTANG
5adb2f83e5 Update AssetBundleCollectorSetting.asset 2024-03-29 14:38:44 +08:00
ALEXTANG
f10a89180e 支持边玩边下载,合理化webgl下的流程
支持边玩边下载,合理化webgl下的流程
2024-03-28 15:55:27 +08:00
ALEXTANG
3e3314858e 优化加载游戏物体接口,常用Parent参数前置,编辑器模式下增加超时保护提示
优化加载游戏物体接口,常用Parent参数前置,编辑器模式下增加超时保护提示
2024-03-25 14:27:42 +08:00
ALEXTANGXIAO
da57ed845f 修正同时对一个资源进行异步加载的处理
修正同时对一个资源进行异步加载的处理
2024-03-24 15:58:57 +08:00
ALEXTANGXIAO
df570f453a Create UnityEditor.iOS_I2Loc.Xcode.dll 2024-03-24 15:50:44 +08:00
ALEXTANG
a500a08a30 更新Luban配置表使用文档 2024-03-19 14:25:48 +08:00
ALEXTANG
2daac0e065 默认一键打包使用ClearAndCopyAll 2024-03-19 14:09:27 +08:00
ALEXTANG
514da6e99e Update README.md 2024-03-18 15:44:29 +08:00
ALEXTANG
7f91241df7 Update Version.cs 2024-03-18 15:06:48 +08:00
ALEXTANG
071974ab4f Update GameLogic.asmdef 2024-03-18 15:05:40 +08:00
ALEXTANG
c01e03ff70 Update AssetBundleCollectorSetting.asset 2024-03-18 15:02:23 +08:00
ALEXTANG
6fec792e05 TEngine全面更新,升级YooAsset2.1.1、UniTask、UIWindow、I2Localization
TEngine全面更新,升级YooAsset2.1.1、UniTask、UIWindow、I2Localization
2024-03-18 14:53:26 +08:00
ALEXTANG
04ecf71eab Update ProcedureLoadAssembly.cs 2024-02-27 12:05:26 +08:00
ALEXTANG
693ca5bb3d 编辑器模式重定向所有热更dll,以防编辑器运行AB时出现两份元数据。
编辑器模式重定向所有热更dll,以防编辑器运行AB时出现两份元数据。
2024-01-25 15:10:30 +08:00
ALEXTANG
90f84a2764 更新README
更新README
2023-12-20 12:43:39 +08:00
ALEXTANG
6107b41770 修正动态添加/异步添加ui组件的脏数据问题
修正动态添加/异步添加ui组件的脏数据问题
2023-12-19 18:24:33 +08:00
ALEXTANG
1423a3716a 编辑器模式重定向所有热更dll,以防编辑器运行AB时出现两份元数据。
编辑器模式重定向所有热更dll,以防编辑器运行AB时出现两份元数据。
2023-12-18 19:49:46 +08:00
ALEXTANG
6a87db76ee 优化局部单位事件分发器ActorEventDispatcher,EventRegInfo池化
优化局部单位事件分发器ActorEventDispatcher,EventRegInfo池化
2023-12-15 15:11:12 +08:00
ALEXTANG
3a6170dca6 Update UIWidget.cs 2023-12-15 14:25:41 +08:00
ALEXTANG
9d137d613a 修正Utility.Unity注入非Mono的LateUpdate时序问题
修正Utility.Unity注入非Mono的LateUpdate时序问题
2023-12-15 14:15:08 +08:00
ALEXTANG
ba77ec6b45 Update EventInterfaceGenerate.cs 2023-12-14 15:07:04 +08:00
ALEXTANG
b661da68f2 Update EventInterfaceGenerate.cs 2023-12-14 10:12:56 +08:00
ALEXTANGXIAO
e1040110bb 升级拓展GameEvent,支持基于Interface的方法调用抛出事件,以及自动化根据声明的Interface来生成实现代码。
升级拓展GameEvent,支持基于Interface的方法调用抛出事件,以及自动化根据声明的Interface来生成实现代码。
2023-12-13 23:27:54 +08:00
ALEXTANGXIAO
2d53fa1687 升级HybridCLR 4.0.13=>4.0.14
升级HybridCLR 4.0.13=>4.0.14
2023-12-13 19:27:05 +08:00
ALEXTANG
c4ef07f13e Update UnityExtension.cs 2023-12-12 13:00:53 +08:00
ALEXTANG
1f2d99ddc9 修正UIWindow资源句柄时序导致UI同步显示失效的问题。 2023-12-08 10:38:19 +08:00
ALEXTANG
edf4925a7a UIWidget增加Visible设置
UIWidget增加Visible设置
2023-12-07 16:32:54 +08:00
ALEXTANG
5d67238c8f 统一封装对shader的管理和示例。
统一封装对shader的管理和示例。
2023-12-07 10:55:50 +08:00
ALEXTANG
6cfd352482 关闭ResourceCacheMgr测试日志
关闭ResourceCacheMgr测试日志
2023-12-07 10:30:50 +08:00
ALEXTANG
40373c473d 修改通过Tag加载资源对象集合接口。(Operation需要自行管理生命周期释放)
修改通过Tag加载资源对象集合接口。(Operation需要自行管理生命周期释放)
2023-12-07 10:27:17 +08:00
ALEXTANG
d799f9fdf0 优化资源引用类与资源分组类。 2023-12-06 17:57:54 +08:00
ALEXTANG
15735c3d2d 修正循环列表GetItem,增加普通列表组件。 2023-12-06 14:41:31 +08:00
ALEXTANG
818a74f437 释放资源前判断资源合法性 2023-12-06 11:35:33 +08:00
ALEXTANG
f248757401 消除Editor引用隐患
消除Editor引用隐患
2023-12-01 17:41:43 +08:00
ALEXTANG
6ada0e7de7 移除测试日志 2023-12-01 17:18:13 +08:00
ALEXTANG
7ea472f97e 修正日志重定向下层日志跳转功能
修正日志重定向下层日志跳转功能
2023-12-01 10:45:57 +08:00
ALEXTANG
fb8528ff52 音频代理类增加暂停和取消暂停接口。
音频代理类增加暂停和取消暂停接口。
2023-11-30 16:17:35 +08:00
ALEXTANG
e3ac92ef46 修正音频模块回收池
修正音频模块回收池
2023-11-30 15:30:01 +08:00
ALEXTANG
be6a19c26a 修正Sound轨道不受SoundVolume的影响,调整AudioMixer音频Group命名
修正Sound轨道不受SoundVolume的影响,调整AudioMixer音频Group命名
2023-11-30 13:18:20 +08:00
ALEXTANG
e7f0636f30 拓展细分内存对象生命周期。
拓展细分内存对象生命周期。
2023-11-30 00:13:23 +08:00
ALEXTANG
fb38e96e9e 修正循环列表根据下标获取索引Item
修正循环列表根据下标获取索引Item
2023-11-29 19:48:18 +08:00
ALEXTANG
dd658c7e1d 对象池支持ShutDown
对象池支持ShutDown
2023-11-29 15:39:44 +08:00
ALEXTANG
4d7cb7641d 修正LoadGameObjectAsync接口传参
修正LoadGameObjectAsync接口传参
2023-11-29 15:24:02 +08:00
ALEXTANG
ae075b1fad 修正ProcedureDownloadFile更新时网速计算
修正ProcedureDownloadFile更新时网速计算
2023-11-29 12:55:36 +08:00
ALEXTANG
02827ce3b8 优化/新增超牛逼且很方便使用的对象池。
优化/新增超牛逼且很方便使用的对象池。
2023-11-28 19:36:26 +08:00
ALEXTANG
1a0e3f91e0 优化/新增超牛逼且很方便使用的对象池。
优化/新增超牛逼且很方便使用的对象池。
2023-11-28 15:27:34 +08:00
ALEXTANG
6d376b0e07 增加安全定时器GameTimerTick
增加安全定时器GameTimerTick
2023-11-28 14:25:25 +08:00
ALEXTANGXIAO
cb73c9a9eb 升级HybridCLR 4.0.12=>4.0.13 强烈建议升级,修复了若干bug
升级HybridCLR 4.0.12=>4.0.13 强烈建议升级,修复了若干bug
2023-11-27 22:47:30 +08:00
ALEXTANG
7dda73a7ac 增加泛用加载资源并绑定资源引用到GameObject上。
增加泛用加载资源并绑定资源引用到GameObject上。
2023-11-23 13:34:33 +08:00
ALEXTANG
9bcb636ed7 修正SetSprite接口绑定资源引用关系,避免0引用导致AssetBundle被释放使图片丢失。
修正SetSprite接口绑定资源引用关系,避免0引用导致AssetBundle被释放使图片丢失。
2023-11-23 11:44:43 +08:00
ALEXTANG
bd0cfc5577 增加计时器TimerModule。
增加计时器TimerModule。
2023-11-22 12:20:08 +08:00
ALEXTANG
ff613e4130 更新修复导入图集初始化信息不全的bug
更新修复导入图集初始化信息不全的bug
2023-11-20 17:49:08 +08:00
ALEXTANG
fea1ae2278 Merge pull request #59 from AlanWeekend/main
优化分包资源下载逻辑,统一WebGL平台与其他平台的远程热更资源引用方式
2023-11-20 11:56:04 +08:00
Weekend
866c440479 add:初始化Package流程中增加webgl平台更新update配置 2023-11-19 02:01:15 +08:00
Weekend
48ff839d64 Merge branch 'main' of https://github.com/AlanWeekend/TEngine 2023-11-19 01:43:59 +08:00
Weekend
69be3cfa23 update:统一WebGL平台与其他平台的远程热更资源引用方式 2023-11-19 01:41:47 +08:00
Weekend
5f2c27ecf0 Merge branch 'ALEXTANGXIAO:main' into main 2023-11-18 21:46:00 +08:00
Weekend
ef17cd851b add:优化分包下载 2023-11-18 21:44:24 +08:00
ALEXTANG
f186d6b058 Merge pull request #58 from AlanWeekend/main
增加初始化指定资源包操作,单独下载指定地址的资源文件
2023-11-16 10:52:14 +08:00
Weekend
4385123976 add:设置图片资源支持从指定资源包中加载 2023-11-15 15:39:04 +08:00
Weekend
1334dc30f9 Merge branch 'main' of https://github.com/AlanWeekend/TEngine 2023-11-15 15:15:11 +08:00
Weekend
af822add2c add:下载资源包中指定地址的资源文件 2023-11-15 15:14:47 +08:00
Weekend
ffb1f214ad Merge branch 'ALEXTANGXIAO:main' into main 2023-11-15 14:41:45 +08:00
Weekend
213aaed426 add:初始化指定资源包 2023-11-15 14:40:35 +08:00
ALEXTANG
623d301e41 修正异步创建子Widget时SetParent的问题
修正异步创建子Widget时SetParent的问题
2023-11-15 14:06:49 +08:00
ALEXTANG
2870383afe Resource模块支持操作指定资源包的资源
Resource模块支持操作指定资源包的资源
2023-11-15 10:48:28 +08:00
ALEXTANG
1ad435958a Merge pull request #57 from AlanWeekend/main
add:Resource模块支持操作指定资源包的资源
2023-11-15 10:08:53 +08:00
Weekend
386787c6ec add:Resource模块支持操作指定资源包的资源 2023-11-15 00:14:07 +08:00
ALEXTANG
cd65dde4c3 ReleasePreLoadAssets修正在webgl模式下Shutdown的问题
ReleasePreLoadAssets修正在webgl模式下Shutdown的问题
2023-11-14 16:00:09 +08:00
ALEXTANG
8321e77421 Merge pull request #56 from AlanWeekend/main
fixed:looplistitem重复赋值问题
2023-11-13 13:09:25 +08:00
Weekend
1b6f80952e fixed:looplistitem重复赋值问题
fixed:looplistitem重复赋值问题
2023-11-12 19:49:02 +08:00
ALEXTANG
b52e655c30 更正错误注释
更正错误注释
2023-11-07 11:04:59 +08:00
ALEXTANG
8c0df95626 修正CancellationTokenSource重复Dispose问题
修正CancellationTokenSource重复Dispose问题
2023-11-03 16:58:42 +08:00
ALEXTANG
0d1e308f1c Update ResourceModule.cs 2023-11-03 10:07:25 +08:00
ALEXTANG
f8797538fd Update UIBase.cs 2023-11-03 09:55:36 +08:00
ALEXTANG
fe4e168041 Update ProcedurePreload.cs 2023-11-02 15:35:01 +08:00
ALEXTANG
8e9047d3a3 基于资源框架实现对标签WEBGL_PRELOAD、PRELOAD的预加载。 接口GameModule.Resource.GetPreLoadAsset<T>(location)
基于资源框架实现对标签WEBGL_PRELOAD、PRELOAD的预加载。 接口GameModule.Resource.GetPreLoadAsset<T>(location)
2023-11-02 13:16:05 +08:00
ALEXTANG
04bfaeccc8 示例CLI工作流
示例CLI工作流
2023-11-02 12:55:27 +08:00
ALEXTANG
d66c823c15 更新优化启用UpdateData时UILoadUpdate时序的问题
更新优化启用UpdateData时UILoadUpdate时序的问题
2023-11-02 11:48:47 +08:00
ALEXTANG
0ec1424f0a 升级HybridCLR 4.0.11=>4.0.12
升级HybridCLR 4.0.11=>4.0.12
2023-11-02 11:12:56 +08:00
1126 changed files with 59851 additions and 35488 deletions

View File

@@ -1,16 +1,16 @@
# TEngine
## TEngine-Runtime
### AOT内核基于Gameframework,最简化以及商业化适配。
### AOT内核基于Gameframework,优化、最简化以及商业化适配。
![image](src/2-1.png)
## AOT游戏框架模块基类。
#### 框架思路为面向接口编程如Resource资源模块开发白皮书为先定义IResourceManager的接口规范然后编写ResourceManager继承框架具体实现(GameFrameworkModule)以及实现接口。最后实现调用层GameFrameworkModuleBase,调用层可以拓展编辑器供开发者自定义模块参数。
#### 框架思路为面向接口编程如Resource资源模块开发白皮书为先定义IResourceManager的接口规范然后编写ResourceManager继承框架具体实现(ModuleImp)以及实现接口。最后实现调用层Module调用层可以拓展编辑器供开发者自定义模块参数。
``` csharp
/// <summary>
/// 游戏框架模块抽象类。GameFrameworkModule为具体框架模块实现。
/// 游戏框架模块抽象类。ModuleImp为具体框架模块实现。
/// </summary>
internal abstract class GameFrameworkModule
internal abstract class ModuleImp
{
/// <summary>
/// 获取游戏框架模块优先级。
@@ -34,16 +34,16 @@ internal abstract class GameFrameworkModule
//=====================================================================//
/// <summary>
/// 游戏框架模块抽象类。GameFrameworkModuleBase 为Mono调用层。
/// 游戏框架模块抽象类。Module 为Mono调用层。
/// </summary>
public abstract class GameFrameworkModuleBase : MonoBehaviour
public abstract class Module : MonoBehaviour
{
/// <summary>
/// 游戏框架模块初始化。
/// </summary>
protected virtual void Awake()
{
GameEntry.RegisterModule(this);
ModuleSystem.RegisterModule(this);
}
}
```

View File

@@ -1,11 +1,19 @@
# 3-6.配置表模块 - ConfigLoader
# 3-6.配置表模块 - ConfigSystem
接入最佳游戏配置解决方案 - <a href="https://github.com/focus-creative-games/luban"><strong>Luban</strong></a>
<a href="https://luban.doc.code-philosophy.com/#/manual/traits"><strong>Luban文档 </strong></a>
### 在TEngine中Luban工具集位于以下目录
### 在TEngine中Luban配置表目录位于以下目录
![image](src/3-6-1.png)
### 安装luban配置表
1.在TEngine根目录同级克隆下最新的luban-next仓库。
![image](src/3-6-2.png)
2.Tools目录执行build-luban完成
![image](src/3-6-3.png)
3.转表则去luban配置目录执行对应bat
TEngine内置默认使用懒加载配置也支持基于UniTask的异步加载同步加载包括服务器的Task异步加载使用对应转表的bat即可。
### 介绍

View File

@@ -14,3 +14,10 @@
### IOS真机运行
![image](src/Iphone-RunSuccessed.png)
### 索尼 PS5 真机运行
![image](src/Console%20Viewer.png)
![image](src/Console%20Output.png)

16
Books/Donate.md Normal file
View File

@@ -0,0 +1,16 @@
## <strong>Buy me a coffee.
您的赞助会让我们做得更快更好如果觉得TEngine对您有帮助不妨赞助我买杯咖啡吧~
<p align="center">
<img src="src/Donate-微信.jpg" alt="logo" width="384" height="562">
</p>
<p align="center">
<img src="src/Donate-支付宝.jpg" alt="logo" width="384" height="562">
</p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 74 KiB

BIN
Books/src/3-6-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
Books/src/3-6-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

BIN
Books/src/Donate-微信.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

View File

@@ -0,0 +1,9 @@
cd /d %~dp0
call path_define.bat
%UNITYEDITOR_PATH%/Unity.exe %WORKSPACE% -logFile %BUILD_LOGFILE% -executeMethod TEngine.ReleaseTools.AutomationBuildAndroid -quit -batchmode -CustomArgs:Language=en_US; %WORKSPACE%
@REM for /f "delims=[" %%i in (%BUILD_LOGFILE%) do echo %%i
pause

6
BuildCLI/path_define.bat Normal file
View File

@@ -0,0 +1,6 @@
cd /d %~dp0
set WORKSPACE=G:/github/TEngine/UnityProject
set UNITYEDITOR_PATH=G:/UnityEditor/2021.3.20f1c1/Editor
set BUILD_DLL_LOGFILE=./build_dll.log
set BUILD_LOGFILE=./build.log

View File

@@ -42,8 +42,9 @@ public class ConfigSystem : Singleton<ConfigSystem>
/// <returns>ByteBuf</returns>
private ByteBuf LoadByteBuf(string file)
{
var textAssets = GameModule.Resource.LoadAsset<TextAsset>(file);
byte[] ret = textAssets.bytes;
return new ByteBuf(ret);
TextAsset textAsset = GameModule.Resource.LoadAsset<TextAsset>(file);
byte[] bytes = textAsset.bytes;
GameModule.Resource.UnloadAsset(textAsset);
return new ByteBuf(bytes);
}
}

View File

@@ -1,3 +1,6 @@
Cd /d %~dp0
echo %CD%
set WORKSPACE=../..
set LUBAN_DLL=%WORKSPACE%\Tools\Luban\Luban.dll
set CONF_ROOT=.

View File

@@ -1,3 +1,6 @@
Cd /d %~dp0
echo %CD%
set WORKSPACE=../..
set LUBAN_DLL=%WORKSPACE%\Tools\Luban\Luban.dll
set CONF_ROOT=.

View File

@@ -1,3 +1,6 @@
Cd /d %~dp0
echo %CD%
set WORKSPACE=../../
set LUBAN_DLL=%WORKSPACE%/Tools/Luban/Luban.dll
set CONF_ROOT=.

View File

@@ -33,9 +33,6 @@
#### TEngine是一个简单(新手友好开箱即用)且强大的Unity框架全平台解决方案,对于需要一套上手快、文档清晰、高性能且可拓展性极强的商业级解决方案的开发者或者团队来说是一个很好的选择。
## <a href="http://1.12.241.46:5000/"><strong>文档快速入门 »</strong></a>
## 文档快速预览 - 5分钟
* [全平台跑通示意](Books/99-各平台运行RunAble.md): 全平台跑通示意。
* [01_介绍](Books/0-介绍.md): 简单介绍。
@@ -46,27 +43,23 @@
* [06_对象池模块](Books/3-4-%E5%AF%B9%E8%B1%A1%E6%B1%A0%E6%A8%A1%E5%9D%97.md): 展示对象池模块概览。
* [07_配置表模块](Books/3-6-%E9%85%8D%E7%BD%AE%E8%A1%A8%E6%A8%A1%E5%9D%97.md): 展示配置表模块概览。
* [08_流程模块](Books/3-7-%E6%B5%81%E7%A8%8B%E6%A8%A1%E5%9D%97.md): 展示商业化流程模块。
* [09_UI模块](Books/3-5-UI模块.md): 展示商业化UI模块。
## <strong>为什么要使用TEngine
0. 开箱即用5分钟即可上手整套开发流程代码整洁思路清晰功能强大。高内聚低耦合。您可以很轻易的把您不需要的模块进行移除替换。
1. 严格按照商业要求使用次世代的HybridClr进行热更新、最佳的Luban配置表(TEngine支持懒加载、异步加载、同步加载配置。)、百万DAU游戏验证过的YooAsset资源框架框架管理资源引用与释放。全平台热更新流程已跑通。
2. 严格按照商业化流程执行的热更新、商业化的UI开发流程、以及资源管理等等设计并实现了YooAsset资源自动释放、支持LRU、ARC严格管理资源内存。
3. C#双端解决方案服务器使用Fantasy是一套源于ETServer但极为简洁性能更强更好上手的一套商业级服务器框架
4. 支持全平台已有项目使用TEngine上架Steam、Wechat-minigame、AppStore。
3. 支持全平台已有项目使用TEngine上架Steam、Wechat-minigame、AppStore
## <strong>资源重要拓展概念
* AssetReference (资源引用标识) 通用加载资源的时候绑定一个引用标识使你无需关心手动Dispose资源句柄。
## <strong>最新的Demo飞机大战位于demo分支
* AssetGroup资源组数据进行资源分组绑定管理内存中的生命周期资源生命周期托管给资源组的根节点进行Dispose。
## <strong>服务器相关
TEngine本身为纯净的客户端。不强绑定任何服务器。但是个人开发以及中小型公司开发双端则推荐C#服务器
* LruCacheTable (Least Recently Used Cache缓存表)
* ArcCacheTable (Adaptive Replacement Cache缓存表)
## <strong>为什么服务器使用C#
Net Core现在已经更新到了8.0的版本在性能和设计上其实是远超JAVA和GO。在JAVAER还在为JVM更新和添加更多功能时其实他们已经被国内大环境所包围了看不到.Net Core的性能之强组件化的结构。国内大环境是JAVA和GO的天下这个不可否认但是国外C#也确实很多。其实.Net Core最大的问题是大多数自己人都不知道他的优点(AOT、JIT混合编译、热重载等等)甚至很多守旧派抵制core。GO喜欢吹性能但其实目前来看除了协程的轻量级大多数性能测试其实不如JAVA和.Net。简单可以说出了C++的性能以外Net Core其实都打得过。
<strong>当然作为商业级解决方案服务器的耦合度也极低,如果不喜欢您也可以很轻松直接移除替换成你的服务器。</strong>
需要服务器可以合并<a href="https://github.com/ALEXTANGXIAO/GameNetty"><strong>GameNetty</strong></a>过来或者分支Fantasy为接好的带有Fantasy服务器的双端分支。
## <strong>项目结构概览
```
@@ -85,6 +78,11 @@ Assets
└── GameLogic // 游戏业务逻辑程序集 [Dll]
├── GameApp.cs // 热更主入口
└── GameApp_RegisterSystem.cs // 热更主入口注册系统
TEngine
├── Editor // TEngine编辑器核心代码
└── Runtime // TEngine运行时核心代码
```
- 必要:项目使用了以下第三方插件,请自行购买导入:
@@ -99,7 +97,14 @@ Assets
#### <a href="https://github.com/focus-creative-games/hybridclr"><strong>HybridCLR</strong></a> - 特性完整、零成本、高性能、低内存的近乎完美的Unity全平台原生c#热更方案
#### <a href="https://github.com/qq362946/Fantasy"><strong>Fantasy</strong></a> - Fantasy是一套源于ETServer但极为简洁性能更强,更好上手的一套商业级服务器框架。
#### <a href="https://github.com/qq362946/Fantasy"><strong>Fantasy</strong></a> - Fantasy是一套源于ETServer但极为简洁更好上手的一套商业级服务器框架。
#### <a href="https://github.com/ALEXTANGXIAO/GameNetty"><strong>GameNetty</strong></a> - GameNetty是一套源于ETServer首次拆分最新的ET8.1的前后端解决方案客户端最精简大约750k完美做成包的形式几乎零成本 无侵入的嵌入进你的框架。
## <strong>交流群
### <a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MzOcQIzGVLQ5AC5LHaqqA3h_F6lZ_DX4&authKey=LctqAWGHkJ7voQvuj1oaSe5tsGrc1XmQG3U4QniieGUlxY3lC7FtDIpEvPOX0vT8&noverify=0&group_code=862987645">群 号862987645 </strong></a>
## <strong>Buy me a 奶茶.
[您的赞助会让我们做得更快更好如果觉得TEngine对您有帮助不妨请我可爱的女儿买杯奶茶吧~](Books/Donate.md)

View File

@@ -90,6 +90,7 @@ Sandbox/
# [Aa]ssets/Plugins/Sirenix.meta
#YooAssets
package/
yoo/
[Aa]ssets/TEngine/AssetSetting/Resources/BuiltinFileManifest.asset
[Aa]ssets/TEngine/AssetSetting/Resources/BuiltinFileManifest.asset.meta

View File

@@ -1,14 +1,13 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!612988286 &4096168566840163508
SpriteAtlasAsset:
--- !u!687078895 &4343727234628468602
SpriteAtlas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: UIRaw_Atlas_Common
m_MasterAtlas: {fileID: 0}
m_ImporterData:
m_EditorData:
serializedVersion: 2
textureSettings:
serializedVersion: 2
@@ -34,6 +33,30 @@ SpriteAtlasAsset:
m_Overridden: 1
m_AndroidETC2FallbackOverride: 0
m_ForceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
m_BuildTarget: Android
m_MaxTextureSize: 2048
m_ResizeAlgorithm: 0
m_TextureFormat: 50
m_TextureCompression: 1
m_CompressionQuality: 100
m_CrunchedCompression: 0
m_AllowsAlphaSplitting: 0
m_Overridden: 1
m_AndroidETC2FallbackOverride: 0
m_ForceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
m_BuildTarget: WebGL
m_MaxTextureSize: 2048
m_ResizeAlgorithm: 0
m_TextureFormat: 50
m_TextureCompression: 1
m_CompressionQuality: 50
m_CrunchedCompression: 0
m_AllowsAlphaSplitting: 0
m_Overridden: 1
m_AndroidETC2FallbackOverride: 0
m_ForceMaximumCompressionQuality_BC6H_BC7: 0
packingSettings:
serializedVersion: 2
padding: 2
@@ -50,6 +73,19 @@ SpriteAtlasAsset:
- {fileID: 21300000, guid: d623a2b7e069a4c4592d3da48f476189, type: 3}
- {fileID: 21300000, guid: 57e4117f4cd6ae54284898652e70d553, type: 3}
bindAsDefault: 1
isAtlasV2: 1
isAtlasV2: 0
cachedData: {fileID: 0}
m_MasterAtlas: {fileID: 0}
m_PackedSprites:
- {fileID: 21300000, guid: 2761fc23b4aa7e34187ac5ffbc3fad9b, type: 3}
- {fileID: 21300000, guid: f9a06e163014f4f46b14f4499d3e7240, type: 3}
- {fileID: 21300000, guid: d623a2b7e069a4c4592d3da48f476189, type: 3}
- {fileID: 21300000, guid: 57e4117f4cd6ae54284898652e70d553, type: 3}
m_PackedSpriteNamesToIndex:
- red_button
- blue_button
- white_background
- white_button
m_RenderDataMap: {}
m_Tag: UIRaw_Atlas_Common
m_IsVariant: 0

View File

@@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: a363de58f5d6e9e438b2b9a692187f6e
guid: c91b064c2cd7a34448ae0d6d7ee58e7f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
mainObjectFileID: 4343727234628468602
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 40c870edb8e84064a8be2d56acb8bbc0
guid: 3b549395c8849674b9cafbbf4c694e57
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6a824de3af698c34bb4343dbb911498b
guid: 4c9eb26aee01e8643bd4e6dc965d3366
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -0,0 +1,40 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2f0b0c553be8edd4682e9180fdd13e37, type: 3}
m_Name: I2Languages
m_EditorClassIdentifier:
mSource:
UserAgreesToHaveItOnTheScene: 0
UserAgreesToHaveItInsideThePluginsFolder: 0
GoogleLiveSyncIsUptoDate: 1
mTerms: []
CaseInsensitiveTerms: 0
OnMissingTranslation: 1
mTerm_AppName:
mLanguages: []
IgnoreDeviceLanguage: 0
_AllowUnloadingLanguages: 0
Google_WebServiceURL:
Google_SpreadsheetKey:
Google_SpreadsheetName:
Google_LastUpdatedVersion:
Google_Password: change_this
GoogleUpdateFrequency: 3
GoogleInEditorCheckFrequency: 2
GoogleUpdateSynchronization: 1
GoogleUpdateDelay: 0
Assets: []
Spreadsheet_LocalFileName:
Spreadsheet_LocalCSVSeparator: ','
Spreadsheet_LocalCSVEncoding: utf-8
Spreadsheet_SpecializationAsRows: 1
Spreadsheet_SortRows: 1

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: b763f43bfb633944aa8955535b965c1f
guid: f069f2f03dfa55843a74dedc551eefb2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

View File

@@ -1,14 +1,14 @@
using TEngine;
using System.Diagnostics;
namespace GameBase
{
/// <summary>
/// 通用单例
/// 全局对象必须继承于此
/// </summary>
/// <typeparam name="T">泛型T。</typeparam>
public class Singleton<T> where T : new()
/// <typeparam name="T">子类类型。</typeparam>
public abstract class Singleton<T> : ISingleton where T : Singleton<T>, new()
{
private static T _instance;
protected static T _instance = default(T);
public static T Instance
{
@@ -17,11 +17,43 @@ namespace GameBase
if (null == _instance)
{
_instance = new T();
Log.Assert(_instance != null);
_instance.Init();
SingletonSystem.Retain(_instance);
}
return _instance;
}
}
public static bool IsValid => _instance != null;
protected Singleton()
{
#if UNITY_EDITOR
string st = new StackTrace().ToString();
// using const string to compare simply
if (!st.Contains("GameBase.Singleton`1[T].get_Instance"))
{
UnityEngine.Debug.LogError($"请必须通过Instance方法来实例化{typeof(T).FullName}类");
}
#endif
}
protected virtual void Init()
{
}
public virtual void Active()
{
}
public virtual void Release()
{
if (_instance != null)
{
SingletonSystem.Release(_instance);
_instance = null;
}
}
}
}

View File

@@ -0,0 +1,108 @@
using TEngine;
using UnityEngine;
namespace GameBase
{
/// <summary>
/// 全局MonoBehavior必须继承于此
/// </summary>
/// <typeparam name="T">子类类型</typeparam>
public class SingletonBehaviour<T> : MonoBehaviour where T : SingletonBehaviour<T>
{
private static T _instance;
private void Awake()
{
if (CheckInstance())
{
OnLoad();
}
}
private bool CheckInstance()
{
if (this == Instance)
{
return true;
}
Object.Destroy(gameObject);
return false;
}
protected virtual void OnLoad()
{
}
protected virtual void OnDestroy()
{
Release();
}
/// <summary>
/// 判断对象是否有效
/// </summary>
public static bool IsValid
{
get
{
return _instance != null;
}
}
public static T Active()
{
return Instance;
}
public static void Release()
{
if (_instance != null)
{
SingletonSystem.Release(_instance.gameObject);
_instance = null;
}
}
/// <summary>
/// 实例
/// </summary>
public static T Instance
{
get
{
if (_instance == null)
{
System.Type thisType = typeof(T);
string instName = thisType.Name;
GameObject go = SingletonSystem.GetGameObject(instName);
if (go == null)
{
go = GameObject.Find($"/{instName}");
if (go == null)
{
go = new GameObject(instName);
go.transform.position = Vector3.zero;
}
SingletonSystem.Retain(go);
}
if (go != null)
{
_instance = go.GetComponent<T>();
if (_instance == null)
{
_instance = go.AddComponent<T>();
}
}
if(_instance == null)
{
Log.Error($"Can't create SingletonBehaviour<{typeof(T)}>");
}
}
return _instance;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bc365e281d234e61891bf9f922a0897a
timeCreated: 1715574965

View File

@@ -0,0 +1,141 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace GameBase
{
public interface ISingleton
{
/// <summary>
/// 激活接口,通常用于在某个时机手动实例化
/// </summary>
void Active();
/// <summary>
/// 释放接口
/// </summary>
void Release();
}
/// <summary>
/// 框架中的全局对象与Unity场景依赖相关的DontDestroyOnLoad需要统一管理方便重启游戏时清除工作
/// </summary>
public static class SingletonSystem
{
private static List<ISingleton> _singletons;
private static Dictionary<string, GameObject> _gameObjects;
public static void Retain(ISingleton go)
{
if (_singletons == null)
{
_singletons = new List<ISingleton>();
}
_singletons.Add(go);
}
public static void Retain(GameObject go)
{
if (_gameObjects == null)
{
_gameObjects = new Dictionary<string, GameObject>();
}
if (_gameObjects.TryAdd(go.name, go))
{
if (Application.isPlaying)
{
Object.DontDestroyOnLoad(go);
}
}
}
public static void Release(GameObject go)
{
if (_gameObjects != null && _gameObjects.ContainsKey(go.name))
{
_gameObjects.Remove(go.name);
Object.Destroy(go);
}
}
public static void Release(ISingleton go)
{
if (_singletons != null && _singletons.Contains(go))
{
_singletons.Remove(go);
}
}
public static void Release()
{
if (_gameObjects != null)
{
foreach (var item in _gameObjects)
{
Object.Destroy(item.Value);
}
_gameObjects.Clear();
}
if (_singletons != null)
{
for (int i = _singletons.Count -1; i >= 0; i--)
{
_singletons[i].Release();
}
_singletons.Clear();
}
Resources.UnloadUnusedAssets();
}
public static GameObject GetGameObject(string name)
{
GameObject go = null;
if (_gameObjects != null)
{
_gameObjects.TryGetValue(name, out go);
}
return go;
}
internal static bool ContainsKey(string name)
{
if (_gameObjects != null)
{
return _gameObjects.ContainsKey(name);
}
return false;
}
public static void Restart()
{
if (Camera.main != null)
{
Camera.main.gameObject.SetActive(false);
}
Release();
SceneManager.LoadScene(0);
}
internal static ISingleton GetSingleton(string name)
{
for (int i = 0; i < _singletons.Count; ++i)
{
if (_singletons[i].ToString() == name)
{
return _singletons[i];
}
}
return null;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4ad00b596d0743a4b04591fe52087d0f
timeCreated: 1715574577

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 40a878a415f34e7a855fc4916bbb8e6b
timeCreated: 1702479104

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1dcaa491f139438dbd963d8bbf0dba85
timeCreated: 1702385397

View File

@@ -0,0 +1,9 @@
using System;
namespace GameLogic
{
[AttributeUsage(AttributeTargets.Class)]
public class BaseAttribute: Attribute
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 819c4eaddddd4646a100da2e3f19c3c7
timeCreated: 1702385397

View File

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Reflection;
namespace GameLogic
{
public class CodeTypes
{
private static CodeTypes _instance;
public static CodeTypes Instance => _instance ??= new CodeTypes();
private readonly Dictionary<string, Type> _allTypes = new();
private readonly UnOrderMultiMapSet<Type, Type> _types = new();
public void Init(Assembly[] assemblies)
{
Dictionary<string, Type> addTypes = GetAssemblyTypes(assemblies);
foreach ((string fullName, Type type) in addTypes)
{
_allTypes[fullName] = type;
if (type.IsAbstract)
{
continue;
}
// 记录所有的有BaseAttribute标记的的类型
object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), true);
foreach (object o in objects)
{
_types.Add(o.GetType(), type);
}
}
}
public HashSet<Type> GetTypes(Type systemAttributeType)
{
if (!_types.ContainsKey(systemAttributeType))
{
return new HashSet<Type>();
}
return _types[systemAttributeType];
}
public Dictionary<string, Type> GetTypes()
{
return _allTypes;
}
public Type GetType(string typeName)
{
return _allTypes[typeName];
}
public static Dictionary<string, Type> GetAssemblyTypes(params Assembly[] args)
{
Dictionary<string, Type> types = new Dictionary<string, Type>();
foreach (Assembly ass in args)
{
foreach (Type type in ass.GetTypes())
{
if (type.FullName != null)
{
types[type.FullName] = type;
}
}
}
return types;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 01fdfc4515314c579523ac3716005210
timeCreated: 1702385429

View File

@@ -0,0 +1,80 @@
using System.Collections.Generic;
namespace GameLogic
{
public class UnOrderMultiMapSet<TKey, TValue>: Dictionary<TKey, HashSet<TValue>>
{
public new HashSet<TValue> this[TKey t]
{
get
{
HashSet<TValue> set;
if (!TryGetValue(t, out set))
{
set = new HashSet<TValue>();
}
return set;
}
}
public Dictionary<TKey, HashSet<TValue>> GetDictionary()
{
return this;
}
public void Add(TKey t, TValue k)
{
HashSet<TValue> set;
TryGetValue(t, out set);
if (set == null)
{
set = new HashSet<TValue>();
base[t] = set;
}
set.Add(k);
}
public bool Remove(TKey t, TValue k)
{
HashSet<TValue> set;
TryGetValue(t, out set);
if (set == null)
{
return false;
}
if (!set.Remove(k))
{
return false;
}
if (set.Count == 0)
{
Remove(t);
}
return true;
}
public bool Contains(TKey t, TValue k)
{
HashSet<TValue> set;
TryGetValue(t, out set);
if (set == null)
{
return false;
}
return set.Contains(k);
}
public new int Count
{
get
{
int count = 0;
foreach (KeyValuePair<TKey,HashSet<TValue>> kv in this)
{
count += kv.Value.Count;
}
return count;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b798f0c1317c4caf9ace168f07b51d4f
timeCreated: 1702385485

View File

@@ -171,7 +171,7 @@ namespace GameLogic
CurState = false;
}
public override void OnDestroy()
protected override void OnDestroy()
{
RemoveNotifyBind();
}

View File

@@ -516,7 +516,7 @@ namespace GameLogic
{
if (paramList is { Count: > 0 })
{
return false;
return true;
}
return false;

View File

@@ -7,14 +7,14 @@ namespace GameLogic
public class RedNoteWidget : UIWidget
{
#region
public override void ScriptGenerator()
protected override void ScriptGenerator()
{
}
#endregion
private Image m_image;
public RedNoteBehaviour m_redNote;
public override void OnCreate()
protected override void OnCreate()
{
m_redNote = CreateWidget<RedNoteBehaviour>(gameObject);
m_image = gameObject.GetComponent<Image>();
@@ -42,10 +42,10 @@ namespace GameLogic
public void SetSprite(string sprite)
{
m_image.SetSprite(sprite);
// m_image.SetSprite(sprite);
}
public override void OnUpdate()
protected override void OnUpdate()
{
/*if (!m_redNote.CurState)
{

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2de5a58f37a4ae64e804f150144da809
guid: 123e7155051957847883c574bf957c7f
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -0,0 +1,49 @@
using UnityEngine;
namespace TEngine
{
/// <summary>
/// 封装一个角色可能用到的各种shader场景。
/// </summary>
class ActorShaderGroup
{
private readonly TShader[] _allShader = new TShader[(int)ActorShaderEnvType.EnvTypeMax];
/// <summary>
/// 增加Shader到角色Shader分组。
/// </summary>
/// <param name="shaderType">当前环境类型。</param>
/// <param name="shader">TShader。</param>
public void AddShader(ActorShaderEnvType shaderType, TShader shader)
{
_allShader[(int)shaderType] = shader;
}
/// <summary>
/// 根据当前环境获取Shader。
/// </summary>
/// <param name="type">当前环境类型。</param>
/// <returns>TShader。</returns>
public TShader GetShader(ActorShaderEnvType type)
{
return _allShader[(int)type];
}
/// <summary>
/// 判断是否符合shader集合。
/// </summary>
/// <param name="shader">Shader实例。</param>
/// <returns>是否符合。</returns>
public bool IsMatch(Shader shader)
{
foreach (var dodShader in _allShader)
{
if (dodShader != null && dodShader.Shader == shader)
{
return true;
}
}
return false;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 79b6e5be73e14c929b6a3b4a980976ac
timeCreated: 1701916950

View File

@@ -0,0 +1,117 @@
using GameBase;
using UnityEngine;
namespace TEngine
{
enum ActorShaderGroupType
{
/// <summary>
/// 通用的角色shader
/// </summary>
Brdf = 0,
/// <summary>
/// 眼睛
/// </summary>
BrdfEye,
///可能后面扩展,比如特效的特殊角色材质
GroupMax,
}
enum ActorShaderEnvType
{
/// <summary>
/// 游戏内场景默认模型不带阴影不带xray不透明效果
/// </summary>
EnvNormal = 0,
/// <summary>
/// 展示场景
/// </summary>
EnvShow,
/// <summary>
/// 带阴影
/// </summary>
EnvShadow,
/// <summary>
/// 带xray默认也带Shadow
/// </summary>
EnvXRay,
/// <summary>
/// 透明渐隐效果
/// </summary>
EnvAlphaFade,
/// <summary>
/// 展示场景没shadow
/// </summary>
EnvShow_NoShadow,
EnvTypeMax
}
/// <summary>
/// 角色Shader管理器。
/// </summary>
class ActorShaderMgr : Singleton<ActorShaderMgr>
{
private readonly ActorShaderGroup[] _allShaderGroup = new ActorShaderGroup[(int)ActorShaderGroupType.GroupMax];
public ActorShaderMgr()
{
CreateBrdfShader();
}
/// <summary>
/// 根据当前Render查找角色的Shader分组。
/// </summary>
/// <param name="render">Render。</param>
/// <returns>角色的Shader分组。</returns>
public ActorShaderGroup FindShaderGroup(Renderer render)
{
var sharedMat = render.sharedMaterial;
if (sharedMat == null)
{
return null;
}
var shader = sharedMat.shader;
foreach (var group in _allShaderGroup)
{
if (group != null && group.IsMatch(shader))
{
return group;
}
}
return null;
}
private void CreateBrdfShader()
{
//通用的效果
var actorShader = new ActorShaderGroup();
actorShader.AddShader(ActorShaderEnvType.EnvNormal, new TShader("TEngine/Actor/ActorBrdf",shaderLocation:"ActorBrdf"));
actorShader.AddShader(ActorShaderEnvType.EnvShow, new TShader("TEngine/Actor/Show/ActorBrdf",shaderLocation:"ActorBrdf_Show"));
actorShader.AddShader(ActorShaderEnvType.EnvShow_NoShadow, new TShader("TEngine/Actor/Show/ActorBrdf_NoShadow",shaderLocation:"ActorBrdf_NoShadow"));
actorShader.AddShader(ActorShaderEnvType.EnvShadow, new TShader("TEngine/Actor/ActorBrdf",shaderLocation:"ActorBrdf_Normal"));
actorShader.AddShader(ActorShaderEnvType.EnvXRay, new TShader("TEngine/Actor/X-Ray",shaderLocation:"X-Ray"));
actorShader.AddShader(ActorShaderEnvType.EnvAlphaFade, new TShader("TEngine/Actor/Fade/ActorBrdf",shaderLocation:"ActorBrdf_Fade"));
_allShaderGroup[(int)ActorShaderGroupType.Brdf] = actorShader;
//眼睛效果
actorShader = new ActorShaderGroup();
actorShader.AddShader(ActorShaderEnvType.EnvNormal, new TShader("TEngine/Actor/ActorEye",shaderLocation:"ActorEye"));
actorShader.AddShader(ActorShaderEnvType.EnvShow, new TShader("TEngine/Actor/Show/ActorEye",shaderLocation:"ActorEye_Show", "MRT_DISABLE", "MRT_ENABLE"));
actorShader.AddShader(ActorShaderEnvType.EnvShadow, new TShader("TEngine/Actor/ActorEye",shaderLocation:"ActorEye"));
actorShader.AddShader(ActorShaderEnvType.EnvXRay, new TShader("TEngine/Actor/ActorEye",shaderLocation:"ActorEye"));
actorShader.AddShader(ActorShaderEnvType.EnvAlphaFade, new TShader("TEngine/Actor/Fade/ActorEye",shaderLocation:"ActorEye_Fade"));
_allShaderGroup[(int)ActorShaderGroupType.BrdfEye] = actorShader;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5a38b9b4bee84fabb1ef8db5292a6db6
timeCreated: 1701916853

View File

@@ -0,0 +1,154 @@
using System.Collections.Generic;
using UnityEngine;
namespace TEngine
{
/// <summary>
/// TShader scripts used for all rendering.
/// <remarks>统一封装对shader的管理。</remarks>
/// </summary>
public class TShader
{
private bool _loaded;
private Shader _shader;
private readonly string _shaderName;
private readonly string _shaderLocation;
private readonly List<string> _keywordOn = new List<string>();
private readonly List<string> _keywordOff = new List<string>();
/// <summary>
/// Shader scripts used for all rendering.
/// </summary>
public Shader Shader
{
get
{
if (!_loaded)
{
_loaded = true;
_shader = FindShader(_shaderLocation,_shaderName);
if (_shader == null)
{
Log.Error($"invalid shader path: {_shaderLocation}, shader name {_shaderName}");
}
}
return _shader;
}
}
/// <summary>
/// 查找Shader。
/// </summary>
/// <param name="shaderLocation">Shader定位地址。</param>
/// <param name="shaderName">Shader名称。</param>
/// <returns>Shader实例。</returns>
public static Shader FindShader(string shaderLocation,string shaderName)
{
Shader shader = GameModule.Resource.LoadAsset<Shader>(shaderLocation);
if (shader != null)
{
return shader;
}
return Shader.Find(shaderName);
}
/// <summary>
/// TShader构造函数。
/// </summary>
/// <param name="shaderName">shader名称。</param>
/// <param name="shaderLocation">shader路径。</param>
public TShader(string shaderName, string shaderLocation)
{
_shaderName = shaderName;
_shaderLocation = shaderLocation;
_shader = null;
}
/// <summary>
/// TShader构造函数。
/// </summary>
/// <param name="shaderName">shader名称。</param>
/// <param name="shaderLocation">shader路径。</param>
/// <param name="keywordOn">开启选项。</param>
/// <param name="keywordOff">关闭选项。</param>
public TShader(string shaderName, string shaderLocation, string keywordOn, string keywordOff)
{
_shaderName = shaderName;
_shaderLocation = shaderLocation;
_shader = null;
_keywordOn.Add(keywordOn);
_keywordOff.Add(keywordOff);
}
/// <summary>
/// TShader构造函数。
/// </summary>
/// <param name="shaderName">shader名称。</param>
/// <param name="shaderLocation">shader路径。</param>
/// <param name="keywordOn">开启选项。</param>
/// <param name="keywordOff">关闭选项。</param>
public TShader(string shaderName, string shaderLocation, string[] keywordOn, string[] keywordOff)
{
_shaderName = shaderName;
_shaderLocation = shaderLocation;
_shader = null;
_keywordOn.AddRange(keywordOn);
_keywordOff.AddRange(keywordOff);
}
/// <summary>
/// 设置Shader效果。
/// </summary>
/// <param name="render">渲染对象。</param>
public void ApplyRender(Renderer render)
{
var sharedMat = render.sharedMaterial;
if (sharedMat != null)
{
//copy一份材质
sharedMat = render.material;
sharedMat.shader = Shader;
foreach (var keyword in _keywordOff)
{
sharedMat.DisableKeyword(keyword);
}
foreach (var keyword in _keywordOn)
{
sharedMat.EnableKeyword(keyword);
}
}
}
/// <summary>
/// 清除shader。
/// </summary>
/// <param name="render">渲染对象。</param>
public void ClearRender(Renderer render)
{
if (_keywordOff.Count <= 0 && _keywordOn.Count <= 0)
{
return;
}
var sharedMat = render.sharedMaterial;
if (sharedMat != null)
{
//copy一份材质。
sharedMat = render.material;
for (int k = 0; k < _keywordOn.Count; k++)
{
sharedMat.DisableKeyword(_keywordOn[k]);
}
for (int k = 0; k < _keywordOff.Count; k++)
{
sharedMat.EnableKeyword(_keywordOff[k]);
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e219233984c14f7d97bc744c07fe13d0
timeCreated: 1698115491

View File

@@ -377,7 +377,7 @@ namespace GameLogic
private GridItemPool TryCreateItemPool(string itemPrefabName)
{
string resPath = itemPrefabName;
GameObject go = GameModule.Resource.LoadAsset<GameObject>(resPath, _containerTrans);
GameObject go = GameModule.Resource.LoadGameObject(resPath, parent: _containerTrans);
if (go != null)
{
go.SetActive(false);

View File

@@ -669,7 +669,7 @@ namespace GameLogic
private ItemPool TryCreateItemPool(string itemPrefabName)
{
string resPath = itemPrefabName;
GameObject go = GameModule.Resource.LoadAsset<GameObject>(resPath, _containerTrans);
GameObject go = GameModule.Resource.LoadGameObject(resPath, parent: _containerTrans);
if (go != null)
{
go.SetActive(false);

View File

@@ -55,7 +55,7 @@ namespace GameLogic
}
}
public override void BindMemberProperty()
protected override void BindMemberProperty()
{
m_selectNode = FindChild("SelectNode");
m_noSelectNode = FindChild("NoSelectNode");

View File

@@ -9,10 +9,10 @@ namespace GameLogic
/// <summary>
/// UI列表Item
/// </summary>
/// <typeparam name="DataT"></typeparam>
public interface IListDataItem<in DataT>
/// <typeparam name="TData"></typeparam>
public interface IListDataItem<in TData>
{
void SetItemData(DataT d);
void SetItemData(TData d);
}
/// <summary>
@@ -86,7 +86,7 @@ namespace GameLogic
{
}
public override void RegisterEvent()
protected override void RegisterEvent()
{
base.RegisterEvent();
AddSelectEvt();
@@ -180,8 +180,7 @@ namespace GameLogic
/// <param name="n"></param>
public void SetDatas(List<DataT> dataList, int n = -1)
{
AdjustItemNum(Mathf.Max(0, n >= 0 ? n : (dataList == null ? 0 : (dataList.Count - dataStartOffset))),
dataList);
AdjustItemNum(Mathf.Max(0, n >= 0 ? n : (dataList == null ? 0 : (dataList.Count - dataStartOffset))), dataList);
}
/// <summary>
@@ -215,8 +214,7 @@ namespace GameLogic
return;
}
var listDataItem = item as IListDataItem<DataT>;
if (listDataItem != null)
if (item is IListDataItem<DataT> listDataItem)
{
listDataItem.SetItemData(GetData(i));
}
@@ -271,8 +269,7 @@ namespace GameLogic
var preIndex = selectIndex;
m_selectIndex = i;
var item = GetItem(preIndex) as IListSelectItem;
if (item != null)
if (GetItem(preIndex) is IListSelectItem item)
{
item.SetSelected(false);
}
@@ -282,13 +279,20 @@ namespace GameLogic
{
item.SetSelected(true);
}
UpdateSnapTargetItem();
if (triggerEvt && funcOnSelectChange != null)
{
funcOnSelectChange.Invoke();
}
}
/// <summary>
/// 刷新Snap
/// </summary>
protected virtual void UpdateSnapTargetItem()
{
}
/// <summary>
/// 获取当前选中的数据
/// </summary>
@@ -319,6 +323,11 @@ namespace GameLogic
return null;
}
/// <summary>
/// 点击选择
/// </summary>
public bool SelectByClick = true;
/// <summary>
/// item被点击
/// </summary>
@@ -331,7 +340,10 @@ namespace GameLogic
funcOnItemClick.Invoke(i);
}
selectIndex = i;
if (SelectByClick)
{
selectIndex = i;
}
}
}
}

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using TEngine;
namespace GameLogic
{
/// <summary>
/// 普通UI列表。
/// </summary>
public class UIListWidget<TItem, TData> : UIListBase<TItem, TData> where TItem : UIWidget, new()
{
/// <summary>
/// item列表。
/// </summary>
protected List<TItem> m_items = new List<TItem>();
/// <summary>
/// item列表。
/// </summary>
public List<TItem> items => m_items;
/// <summary>
/// 设置显示数据。
/// </summary>
/// <param name="n"></param>
/// <param name="datas"></param>
/// <param name="funcItem"></param>
protected override void AdjustItemNum(int n, List<TData> datas = null, Action<TItem, int> funcItem = null)
{
base.AdjustItemNum(n, datas, funcItem);
AdjustIconNum(m_items, n, gameObject.transform, itemBase);
UpdateList(funcItem);
}
/// <summary>
/// 刷新列表。
/// </summary>
/// <param name="funcItem"></param>
protected void UpdateList(Action<TItem, int> funcItem = null)
{
for (var i = 0; i < m_items.Count; i++)
{
UpdateListItem(m_items[i], i, funcItem);
}
}
/// <summary>
/// 获取item
/// </summary>
/// <param name="i"></param>
/// <returns></returns>
public override TItem GetItem(int i)
{
return i >= 0 && i < m_items.Count ? m_items[i] : null;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 96f732d895e94fbc99c904d66ca844ca
timeCreated: 1701844130

View File

@@ -30,19 +30,19 @@ namespace GameLogic
/// </summary>
public List<TItem> items => m_items;
public override void BindMemberProperty()
protected override void BindMemberProperty()
{
base.BindMemberProperty();
LoopRectView = rectTransform.GetComponent<LoopGridView>();
}
public override void OnCreate()
protected override void OnCreate()
{
base.OnCreate();
LoopRectView.InitGridView(0, OnGetItemByIndex);
}
public override void OnDestroy()
protected override void OnDestroy()
{
base.OnDestroy();
m_itemCache.Clear();
@@ -66,6 +66,7 @@ namespace GameLogic
LoopRectView.SetListItemCount(n);
LoopRectView.RefreshAllShownItem();
m_tpFuncItem = null;
UpdateAllItemSelect();
}
/// <summary>
@@ -148,11 +149,20 @@ namespace GameLogic
/// <summary>
/// 获取item
/// </summary>
/// <param name="i"></param>
/// <param name="index"></param>
/// <returns></returns>
public override TItem GetItem(int i)
public override TItem GetItem(int index)
{
return i >= 0 && i < m_items.Count ? m_items[i] : null;
for (var i = 0; i < m_itemCache.Count; i++)
{
var item = m_itemCache.GetValueByIndex(i);
if (item.GetItemIndex() == index)
{
return item;
}
}
return null;
}
/// <summary>
@@ -178,5 +188,21 @@ namespace GameLogic
{
return m_itemCache.GetValueByIndex(index);
}
/// <summary>
/// 刷新所有item选中状态
/// </summary>
/// <returns></returns>
public void UpdateAllItemSelect()
{
var index = selectIndex;
for (var i = 0; i < m_itemCache.Count; i++)
{
if (m_itemCache.GetValueByIndex(i) is IListSelectItem item)
{
item.SetSelected(item.GetItemIndex() == index);
}
}
}
}
}

View File

@@ -10,13 +10,13 @@ namespace GameLogic
private GameFrameworkDictionary<int, T> m_itemCache = new GameFrameworkDictionary<int, T>();
public override void BindMemberProperty()
protected override void BindMemberProperty()
{
base.BindMemberProperty();
LoopRectView = this.rectTransform.GetComponent<LoopListView>();
}
public override void OnDestroy()
protected override void OnDestroy()
{
base.OnDestroy();
m_itemCache.Clear();

View File

@@ -31,19 +31,19 @@ namespace GameLogic
/// </summary>
public List<TItem> items => m_items;
public override void BindMemberProperty()
protected override void BindMemberProperty()
{
base.BindMemberProperty();
LoopRectView = rectTransform.GetComponent<LoopListView>();
}
public override void OnCreate()
protected override void OnCreate()
{
base.OnCreate();
LoopRectView.InitListView(0, OnGetItemByIndex);
}
public override void OnDestroy()
protected override void OnDestroy()
{
base.OnDestroy();
m_itemCache.Clear();
@@ -67,6 +67,7 @@ namespace GameLogic
LoopRectView.SetListItemCount(n);
LoopRectView.RefreshAllShownItem();
m_tpFuncItem = null;
UpdateAllItemSelect();
}
/// <summary>
@@ -147,11 +148,20 @@ namespace GameLogic
/// <summary>
/// 获取item
/// </summary>
/// <param name="i"></param>
/// <param name="index"></param>
/// <returns></returns>
public override TItem GetItem(int i)
public override TItem GetItem(int index)
{
return i >= 0 && i < m_items.Count ? m_items[i] : null;
for (var i = 0; i < m_itemCache.Count; i++)
{
var item = m_itemCache.GetValueByIndex(i);
if (item.GetItemIndex() == index)
{
return item;
}
}
return null;
}
/// <summary>
@@ -186,5 +196,30 @@ namespace GameLogic
{
return m_itemCache.GetValueByIndex(index);
}
/// <summary>
/// 刷新所有item选中状态
/// </summary>
/// <returns></returns>
public void UpdateAllItemSelect()
{
var index = selectIndex;
for (var i = 0; i < m_itemCache.Count; i++)
{
if (m_itemCache.GetValueByIndex(i) is IListSelectItem item)
{
item.SetSelected(item.GetItemIndex() == index);
}
}
}
protected override void UpdateSnapTargetItem()
{
base.UpdateSnapTargetItem();
if (LoopRectView != null && LoopRectView.ItemSnapEnable)
{
LoopRectView.SetSnapTargetItemIndex(selectIndex);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d1f693ff76ae490fbe194855d94e8266
timeCreated: 1702479172

View File

@@ -0,0 +1,20 @@
using System;
using TEngine;
namespace GameLogic
{
/// <summary>
/// 事件接口帮助类。
/// </summary>
internal class EventInterfaceHelper
{
/// <summary>
/// 初始化。
/// </summary>
public static void Init()
{
RegisterEventInterface_Logic.Register(GameEvent.EventMgr);
RegisterEventInterface_UI.Register(GameEvent.EventMgr);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9afaf331ee7249adb5cc0953dfd3413c
timeCreated: 1702379658

View File

@@ -0,0 +1,16 @@
using TEngine;
namespace GameLogic
{
[System.AttributeUsage(System.AttributeTargets.Class)]
internal class EventInterfaceImpAttribute : BaseAttribute
{
private EEventGroup _eGroup;
public EEventGroup EventGroup => _eGroup;
public EventInterfaceImpAttribute(EEventGroup group)
{
_eGroup = group;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8bbf40942b0e4470bb8d8a82577f713c
timeCreated: 1702479403

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: de49bf2e9f0a4fac85851a582e2fb4ed
timeCreated: 1702379835

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bff68b49afffbe54b9d5ff4e4cad4f23
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,70 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by autoBindTool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
using TEngine;
namespace GameLogic
{
public partial class IActorLogicEvent_Event
{
public static readonly int OnMainPlayerDataChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerDataChange");
public static readonly int OnMainPlayerLevelChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerLevelChange");
public static readonly int OnMainPlayerGoldChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerGoldChange");
public static readonly int OnMainPlayerDiamondChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerDiamondChange");
public static readonly int OnMainPlayerBindDiamondChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerBindDiamondChange");
public static readonly int OnMainPlayerCurrencyChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerCurrencyChange");
public static readonly int OnMainPlayerExpChange = RuntimeId.ToRuntimeId("IActorLogicEvent_Event.OnMainPlayerExpChange");
}
[EventInterfaceImp(EEventGroup.GroupLogic)]
public partial class IActorLogicEvent_Gen : IActorLogicEvent
{
private EventDispatcher _dispatcher;
public IActorLogicEvent_Gen(EventDispatcher dispatcher)
{
_dispatcher = dispatcher;
}
public void OnMainPlayerDataChange()
{
_dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerDataChange);
}
public void OnMainPlayerLevelChange()
{
_dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerLevelChange);
}
public void OnMainPlayerGoldChange(System.UInt32 oldVal,System.UInt32 newVal)
{
_dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerGoldChange,oldVal,newVal);
}
public void OnMainPlayerDiamondChange(System.UInt32 oldVal,System.UInt32 newVal)
{
_dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerDiamondChange,oldVal,newVal);
}
public void OnMainPlayerBindDiamondChange(System.UInt32 oldVal,System.UInt32 newVal)
{
_dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerBindDiamondChange,oldVal,newVal);
}
public void OnMainPlayerCurrencyChange(GameLogic.CurrencyType type,System.UInt32 oldVal,System.UInt32 newVal)
{
_dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerCurrencyChange,type,oldVal,newVal);
}
public void OnMainPlayerExpChange(System.UInt64 oldVal,System.UInt64 newVal)
{
_dispatcher.Send(IActorLogicEvent_Event.OnMainPlayerExpChange,oldVal,newVal);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 0bf9618a577c38c40a5ff75c626deb98
guid: 12d7d4edd7d06bc4286ea4af153380c6
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 615ca01c7a524654c91935631f39f570
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by autoBindTool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
using TEngine;
namespace GameLogic
{
public partial class ILoginUI_Event
{
public static readonly int OnRoleLogin = RuntimeId.ToRuntimeId("ILoginUI_Event.OnRoleLogin");
public static readonly int OnRoleLoginOut = RuntimeId.ToRuntimeId("ILoginUI_Event.OnRoleLoginOut");
}
[EventInterfaceImp(EEventGroup.GroupUI)]
public partial class ILoginUI_Gen : ILoginUI
{
private EventDispatcher _dispatcher;
public ILoginUI_Gen(EventDispatcher dispatcher)
{
_dispatcher = dispatcher;
}
public void OnRoleLogin(System.Boolean isReconnect)
{
_dispatcher.Send(ILoginUI_Event.OnRoleLogin,isReconnect);
}
public void OnRoleLoginOut()
{
_dispatcher.Send(ILoginUI_Event.OnRoleLoginOut);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 956a30a2d6a8ac448a99a3215faca1f8
guid: bde7ed0ea10cf29448370b39ecd69a97
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7cf3381dedbf4daeb53e710a5c544204
timeCreated: 1702433587

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 610229edeca4417685ffd07f18b2b9f1
timeCreated: 1702379817

View File

@@ -0,0 +1,38 @@
using System;
using TEngine;
namespace GameLogic
{
/// <summary>
/// 示例货币枚举。
/// </summary>
public enum CurrencyType
{
None,
Gold,
Diamond,
}
/// <summary>
/// 示意逻辑层事件。
/// <remarks> 优化抛出事件,通过接口约束事件参数。</remarks>
/// <remarks> example: GameEvent.Get<IActorLogicEvent>().OnMainPlayerCurrencyChange(CurrencyType.Gold,oldVal,newVal); </remarks>
/// </summary>
[EventInterface(EEventGroup.GroupLogic)]
interface IActorLogicEvent
{
void OnMainPlayerDataChange();
void OnMainPlayerLevelChange();
void OnMainPlayerGoldChange(uint oldVal, uint newVal);
void OnMainPlayerDiamondChange(uint oldVal, uint newVal);
void OnMainPlayerBindDiamondChange(uint oldVal, uint newVal);
void OnMainPlayerCurrencyChange(CurrencyType type, uint oldVal, uint newVal);
void OnMainPlayerExpChange(ulong oldVal, ulong newVal);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8d4558cb74e8462a86f0ee3461f6b7c9
timeCreated: 1702383645

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 90e13cc92c5d42f28b4f5fab599f472a
timeCreated: 1702379805

View File

@@ -0,0 +1,17 @@
using TEngine;
namespace GameLogic
{
/// <summary>
/// 示意UI层事件。
/// <remarks> 优化抛出事件,通过接口约束事件参数。</remarks>
/// <remarks> example: GameEvent.Get<ILoginUI>().OnRoleLogin(isReconnect); </remarks>
/// </summary>
[EventInterface(EEventGroup.GroupUI)]
public interface ILoginUI
{
public void OnRoleLogin(bool isReconnect);
public void OnRoleLoginOut();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 33b45e62bd3447498acfe874017b9a35
timeCreated: 1702433755

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using TEngine;
namespace GameLogic
{
/// <summary>
/// 逻辑层事件接口。
/// </summary>
internal class RegisterEventInterface_Logic
{
/// <summary>
/// 注册逻辑层事件接口。
/// </summary>
/// <param name="mgr">事件管理器。</param>
public static void Register(EventMgr mgr)
{
HashSet<Type> types = CodeTypes.Instance.GetTypes(typeof(EventInterfaceImpAttribute));
foreach (Type type in types)
{
object[] attrs = type.GetCustomAttributes(typeof(EventInterfaceImpAttribute), false);
if (attrs.Length == 0)
{
continue;
}
EventInterfaceImpAttribute httpHandlerAttribute = (EventInterfaceImpAttribute)attrs[0];
if (httpHandlerAttribute.EventGroup != EEventGroup.GroupLogic)
{
continue;
}
object obj = Activator.CreateInstance(type, mgr.Dispatcher);
mgr.Init();
mgr.RegWrapInterface(obj.GetType().GetInterfaces()[0]?.FullName, obj);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b8bdf6c139b44758aa16db2e1837f5d9
timeCreated: 1702379518

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using TEngine;
namespace GameLogic
{
/// <summary>
/// UI层事件接口。
/// </summary>
internal class RegisterEventInterface_UI
{
/// <summary>
/// 注册UI层事件接口。
/// </summary>
/// <param name="mgr">事件管理器。</param>
public static void Register(EventMgr mgr)
{
HashSet<Type> types = CodeTypes.Instance.GetTypes(typeof(EventInterfaceImpAttribute));
foreach (Type type in types)
{
object[] attrs = type.GetCustomAttributes(typeof(EventInterfaceImpAttribute), false);
if (attrs.Length == 0)
{
continue;
}
EventInterfaceImpAttribute httpHandlerAttribute = (EventInterfaceImpAttribute)attrs[0];
if (httpHandlerAttribute.EventGroup != EEventGroup.GroupUI)
{
continue;
}
object obj = Activator.CreateInstance(type, mgr.Dispatcher);
mgr.RegWrapInterface(obj.GetType().GetInterfaces()[0]?.FullName, obj);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f53b67f2cfbe4912bffee9593cd60970
timeCreated: 1702379505

View File

@@ -19,7 +19,7 @@ public partial class GameApp:Singleton<GameApp>
_hotfixAssembly = (List<Assembly>)objects[0];
Log.Warning("======= 看到此条日志代表你成功运行了热更新代码 =======");
Log.Warning("======= Entrance GameApp =======");
Instance.Init();
Instance.Active();
Instance.Start();
Utility.Unity.AddUpdateListener(Instance.Update);
Utility.Unity.AddFixedUpdateListener(Instance.FixedUpdate);
@@ -46,6 +46,7 @@ public partial class GameApp:Singleton<GameApp>
/// <param name="shutdownType">关闭游戏框架类型。</param>
public static void Shutdown(ShutdownType shutdownType)
{
Log.Info("GameApp Shutdown");
if (shutdownType == ShutdownType.None)
{
return;
@@ -59,8 +60,9 @@ public partial class GameApp:Singleton<GameApp>
Utility.Unity.RemoveDestroyListener(Instance.OnDestroy);
Utility.Unity.RemoveOnDrawGizmosListener(Instance.OnDrawGizmos);
Utility.Unity.RemoveOnApplicationPauseListener(Instance.OnApplicationPause);
return;
}
SingletonSystem.Release();
}
private void Start()
@@ -128,6 +130,7 @@ public partial class GameApp:Singleton<GameApp>
var logic = listLogic[i];
logic.OnDestroy();
}
Shutdown(ShutdownType.Restart);
}
private void OnDrawGizmos()

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using GameLogic;
using TEngine;
using UnityEngine;
@@ -6,8 +7,10 @@ public partial class GameApp
{
private List<ILogicSys> _listLogicMgr;
private void Init()
public override void Active()
{
CodeTypes.Instance.Init(_hotfixAssembly.ToArray());
EventInterfaceHelper.Init();
_listLogicMgr = new List<ILogicSys>();
RegisterAllSystem();
InitSystemSetting();

View File

@@ -3,12 +3,11 @@
"rootNamespace": "GameLogic",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:15fc0a57446b3144c949da3e2b9737a9",
"GUID:cbb0d51b565003841ae81cdbaf747114",
"GUID:8f58f15387c7a6f4fad9857024eb47f7",
"GUID:24c092aee38482f4e80715eaa8148782",
"GUID:e34a5702dd353724aa315fb8011f08c3",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:e34a5702dd353724aa315fb8011f08c3"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -2,12 +2,9 @@
"name": "GameProto",
"rootNamespace": "",
"references": [
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:cbb0d51b565003841ae81cdbaf747114",
"GUID:24c092aee38482f4e80715eaa8148782",
"GUID:756335c0388f7114790e504ed368ae1d",
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:e34a5702dd353724aa315fb8011f08c3"
"GUID:f51ebe6a0ceec4240a699833d6309b23"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -1,11 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameProto
{
public class GameProto_Empty
{
}
}

View File

@@ -56,8 +56,8 @@ namespace GameMain
/// </summary>
public static void HideAll()
{
GameModule.UI.CloseWindow<UILoadTip>();
GameModule.UI.CloseWindow<UILoadUpdate>();
GameModule.UI.CloseUI<UILoadTip>();
GameModule.UI.CloseUI<UILoadUpdate>();
}
}
}

View File

@@ -25,7 +25,7 @@ namespace GameMain
private Text m_textInfo;
private Button m_btnIgnore;
private Button m_btnUpdate;
public override void ScriptGenerator()
protected override void ScriptGenerator()
{
m_btnPackage = FindChildComponent<Button>("BgImage/m_btnPackage");
m_textTittle = FindChildComponent<Text>("BgImage/m_textTittle");
@@ -81,8 +81,18 @@ namespace GameMain
#endregion
public override void OnRefresh()
protected override void OnRefresh()
{
OnOk = (Action)userDatas[1];
OnCancel = (Action)userDatas[2];
ShowType = (MessageShowType)userDatas[3];
var loadStyleUI = gameObject.GetComponent<LoadStyle>();
if (loadStyleUI)
{
loadStyleUI.SetStyle((LoadStyle.StyleEnum)userDatas[4]);
}
base.OnRefresh();
m_btnIgnore.gameObject.SetActive(false);
m_btnPackage.gameObject.SetActive(false);
@@ -121,23 +131,7 @@ namespace GameMain
Action onCancel = null,
Action onPackage = null)
{
var operation = GameModule.UI.ShowUI<UILoadTip>(desc);
if (operation == null || operation.Window == null)
{
return;
}
var ui = operation.Window as UILoadTip;
ui.OnOk = onOk;
ui.OnCancel = onCancel;
ui.ShowType = showtype;
ui.OnRefresh();
var loadStyleUI = ui.gameObject.GetComponent<LoadStyle>();
if (loadStyleUI)
{
loadStyleUI.SetStyle(style);
}
GameModule.UI.ShowUI<UILoadTip>(desc,onOk,onCancel,showtype,style);
}
}
}

View File

@@ -16,7 +16,7 @@ namespace GameMain
private Button m_btnClear;
private Text m_textAppid;
private Text m_textResid;
public override void ScriptGenerator()
protected override void ScriptGenerator()
{
m_imgBackGround = FindChildComponent<Image>("m_imgBackGround");
m_textDesc = FindChildComponent<Text>("m_textDesc");
@@ -28,7 +28,7 @@ namespace GameMain
}
#endregion
public override void OnCreate()
protected override void OnCreate()
{
base.OnCreate();
LoadUpdateLogic.Instance.DownloadCompleteAction += DownLoad_Complete_Action;
@@ -38,10 +38,15 @@ namespace GameMain
m_btnClear.gameObject.SetActive(true);
}
public override void OnRefresh()
protected override void RegisterEvent()
{
base.RegisterEvent();
AddUIEvent(RuntimeId.ToRuntimeId("RefreshVersion"),RefreshVersion);
}
protected override void OnRefresh()
{
base.OnRefresh();
RefreshVersion();
}
#region
@@ -118,7 +123,7 @@ namespace GameMain
m_scrollbarProgress.size = progress;
}
public override void OnDestroy()
protected override void OnDestroy()
{
base.OnDestroy();
OnStop(null);

View File

@@ -13,9 +13,18 @@ namespace GameMain
private ProcedureOwner _procedureOwner;
private float CurrentSpeed =>
(GameModule.Resource.Downloader.TotalDownloadBytes -
GameModule.Resource.Downloader.CurrentDownloadBytes) / GameTime.time;
private float _lastUpdateDownloadedSize;
private float CurrentSpeed
{
get
{
float interval = GameTime.deltaTime;
var sizeDiff = GameModule.Resource.Downloader.CurrentDownloadBytes - _lastUpdateDownloadedSize;
_lastUpdateDownloadedSize = GameModule.Resource.Downloader.CurrentDownloadBytes;
var speed = (float)Math.Floor(sizeDiff / interval);
return speed;
}
}
protected override void OnEnter(ProcedureOwner procedureOwner)
{
@@ -63,7 +72,7 @@ namespace GameMain
Utility.File.GetByteLengthString(currentDownloadBytes),
Utility.File.GetByteLengthString(totalDownloadBytes),
GameModule.Resource.Downloader.Progress,
Utility.File.GetByteLengthString((int)CurrentSpeed));
Utility.File.GetLengthString((int)CurrentSpeed));
LoadUpdateLogic.Instance.DownProgressAction?.Invoke(GameModule.Resource.Downloader.Progress);
UILoadMgr.Show(UIDefine.UILoadUpdate,descriptionText);

View File

@@ -29,90 +29,108 @@ namespace GameMain
private async UniTaskVoid InitPackage(ProcedureOwner procedureOwner)
{
if (GameModule.Resource.PlayMode == EPlayMode.HostPlayMode)
try
{
if (SettingsUtils.EnableUpdateData())
if (GameModule.Resource.PlayMode == EPlayMode.HostPlayMode ||
GameModule.Resource.PlayMode == EPlayMode.WebPlayMode)
{
UpdateData updateData = await RequestUpdateData();
if (updateData != null)
if (SettingsUtils.EnableUpdateData())
{
if (!string.IsNullOrEmpty(updateData.HostServerURL))
{
SettingsUtils.FrameworkGlobalSettings.HostServerURL = updateData.HostServerURL;
}
UpdateData updateData = await RequestUpdateData();
if (!string.IsNullOrEmpty(updateData.FallbackHostServerURL))
if (updateData != null)
{
SettingsUtils.FrameworkGlobalSettings.FallbackHostServerURL = updateData.FallbackHostServerURL;
if (!string.IsNullOrEmpty(updateData.HostServerURL))
{
SettingsUtils.FrameworkGlobalSettings.HostServerURL = updateData.HostServerURL;
}
if (!string.IsNullOrEmpty(updateData.FallbackHostServerURL))
{
SettingsUtils.FrameworkGlobalSettings.FallbackHostServerURL =
updateData.FallbackHostServerURL;
}
}
}
}
}
var initializationOperation = GameModule.Resource.InitPackage();
var initializationOperation = await GameModule.Resource.InitPackage();
await UniTask.Delay(TimeSpan.FromSeconds(1f));
await initializationOperation.ToUniTask();
if (initializationOperation.Status == EOperationStatus.Succeed)
{
//热更新阶段文本初始化
LoadText.Instance.InitConfigData(null);
//热更新UI初始化
UILoadMgr.Initialize();
EPlayMode playMode = GameModule.Resource.PlayMode;
// 编辑器模式。
if (playMode == EPlayMode.EditorSimulateMode)
if (initializationOperation.Status == EOperationStatus.Succeed)
{
Log.Info("Editor resource mode detected.");
ChangeState<ProcedurePreload>(procedureOwner);
//热更新阶段文本初始化
LoadText.Instance.InitConfigData(null);
GameEvent.Send(RuntimeId.ToRuntimeId("RefreshVersion"));
EPlayMode playMode = GameModule.Resource.PlayMode;
// 编辑器模式。
if (playMode == EPlayMode.EditorSimulateMode)
{
Log.Info("Editor resource mode detected.");
ChangeState<ProcedurePreload>(procedureOwner);
}
// 单机模式。
else if (playMode == EPlayMode.OfflinePlayMode)
{
Log.Info("Package resource mode detected.");
ChangeState<ProcedureInitResources>(procedureOwner);
}
// 可更新模式。
else if (playMode == EPlayMode.HostPlayMode ||
playMode == EPlayMode.WebPlayMode)
{
// 打开启动UI。
UILoadMgr.Show(UIDefine.UILoadUpdate);
Log.Info("Updatable resource mode detected.");
ChangeState<ProcedureUpdateVersion>(procedureOwner);
}
else
{
Log.Error("UnKnow resource mode detected Please check???");
}
}
// 单机模式。
else if (playMode == EPlayMode.OfflinePlayMode)
{
Log.Info("Package resource mode detected.");
ChangeState<ProcedureInitResources>(procedureOwner);
}
// 可更新模式。
else if (playMode == EPlayMode.HostPlayMode)
else
{
// 打开启动UI。
UILoadMgr.Show(UIDefine.UILoadUpdate);
Log.Info("Updatable resource mode detected.");
ChangeState<ProcedureUpdateVersion>(procedureOwner);
}
// 可更新模式。
else if (playMode == EPlayMode.WebPlayMode)
{
Log.Info("WebPlayMode resource mode detected.");
ChangeState<ProcedurePreload>(procedureOwner);
}
else
{
Log.Error("UnKnow resource mode detected Please check???");
Log.Error($"{initializationOperation.Error}");
// 打开启动UI。
UILoadMgr.Show(UIDefine.UILoadUpdate, $"资源初始化失败!");
UILoadTip.ShowMessageBox(
$"资源初始化失败!点击确认重试 \n \n <color=#FF0000>原因{initializationOperation.Error}</color>",
MessageShowType.TwoButton,
LoadStyle.StyleEnum.Style_Retry
, () => { Retry(procedureOwner); }, UnityEngine.Application.Quit);
}
}
else
catch (Exception e)
{
// 打开启动UI。
UILoadMgr.Show(UIDefine.UILoadUpdate);
Log.Error($"{initializationOperation.Error}");
// 打开启动UI。
UILoadMgr.Show(UIDefine.UILoadUpdate, $"资源初始化失败!");
UILoadTip.ShowMessageBox($"资源初始化失败!点击确认重试 \n \n <color=#FF0000>原因{initializationOperation.Error}</color>", MessageShowType.TwoButton,
LoadStyle.StyleEnum.Style_Retry
, () => { Retry(procedureOwner); }, UnityEngine.Application.Quit);
OnInitPackageFailed(procedureOwner, e.Message);
}
}
private void OnInitPackageFailed(ProcedureOwner procedureOwner, string message)
{
// 打开启动UI。
UILoadMgr.Show(UIDefine.UILoadUpdate);
Log.Error($"{message}");
// 打开启动UI。
UILoadMgr.Show(UIDefine.UILoadUpdate, $"资源初始化失败!");
UILoadTip.ShowMessageBox($"资源初始化失败!点击确认重试 \n \n <color=#FF0000>原因{message}</color>", MessageShowType.TwoButton,
LoadStyle.StyleEnum.Style_Retry
, () => { Retry(procedureOwner); },
Application.Quit);
}
private void Retry(ProcedureOwner procedureOwner)
{
// 打开启动UI。

View File

@@ -15,6 +15,9 @@ namespace GameMain
{
base.OnEnter(procedureOwner);
//热更新UI初始化
UILoadMgr.Initialize();
// 语言配置:设置当前使用的语言,如果不设置,则默认使用操作系统语言
InitLanguageSettings();

View File

@@ -2,7 +2,9 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
#if ENABLE_HYBRIDCLR
using HybridCLR;
#endif
using UnityEngine;
using TEngine;
using System.Reflection;
@@ -15,11 +17,6 @@ namespace GameMain
/// </summary>
public class ProcedureLoadAssembly : ProcedureBase
{
/// <summary>
/// 是否需要加载热更新DLL
/// </summary>
public bool NeedLoadDll => (int)GameModule.Resource.PlayMode > (int)EPlayMode.EditorSimulateMode;
private bool m_enableAddressable = true;
public override bool UseNativeDialog => true;
private int m_LoadAssetCount;
@@ -59,7 +56,7 @@ namespace GameMain
m_LoadMetadataAssemblyComplete = true;
}
if (!NeedLoadDll || GameModule.Resource.PlayMode == EPlayMode.EditorSimulateMode)
if (!SettingsUtils.HybridCLRCustomGlobalSettings.Enable || GameModule.Resource.PlayMode == EPlayMode.EditorSimulateMode)
{
m_MainLogicAssembly = GetMainLogicAssembly();
}
@@ -81,7 +78,7 @@ namespace GameMain
Log.Debug($"LoadAsset: [ {assetLocation} ]");
m_LoadAssetCount++;
GameModule.Resource.LoadAssetAsync<TextAsset>(assetLocation,LoadAssetSuccess);
GameModule.Resource.LoadAsset<TextAsset>(assetLocation,LoadAssetSuccess);
}
m_LoadAssemblyWait = true;
@@ -116,8 +113,7 @@ namespace GameMain
{
ChangeState<ProcedureStartGame>(m_procedureOwner);
#if UNITY_EDITOR
m_MainLogicAssembly = AppDomain.CurrentDomain.GetAssemblies().
First(assembly => $"{assembly.GetName().Name}.dll" == SettingsUtils.HybridCLRCustomGlobalSettings.LogicMainDllName);
m_MainLogicAssembly = GetMainLogicAssembly();
#endif
if (m_MainLogicAssembly == null)
{
@@ -142,6 +138,7 @@ namespace GameMain
private Assembly GetMainLogicAssembly()
{
m_HotfixAssemblys.Clear();
Assembly mainLogicAssembly = null;
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
@@ -171,20 +168,19 @@ namespace GameMain
/// <summary>
/// 加载代码资源成功回调。
/// </summary>
/// <param name="assetOperationHandle">资源操作句柄。</param>
private void LoadAssetSuccess(AssetOperationHandle assetOperationHandle)
/// <param name="textAsset">代码资产。</param>
private void LoadAssetSuccess(TextAsset textAsset)
{
m_LoadAssetCount--;
var assetName = assetOperationHandle.AssetObject.name;
Log.Debug($"LoadAssetSuccess, assetName: [ {assetName} ]");
var textAsset = assetOperationHandle.AssetObject as TextAsset;
if (textAsset == null)
{
Log.Warning($"Load text asset [ {assetName} ] failed.");
Log.Warning($"Load Assembly failed.");
return;
}
var assetName = textAsset.name;
Log.Debug($"LoadAssetSuccess, assetName: [ {assetName} ]");
try
{
var assembly = Assembly.Load(textAsset.bytes);
@@ -205,7 +201,7 @@ namespace GameMain
{
m_LoadAssemblyComplete = m_LoadAssemblyWait && 0 == m_LoadAssetCount;
}
assetOperationHandle.Dispose();
GameModule.Resource.UnloadAsset(textAsset);
}
/// <summary>
@@ -239,7 +235,7 @@ namespace GameMain
Log.Debug($"LoadMetadataAsset: [ {assetLocation} ]");
m_LoadMetadataAssetCount++;
GameModule.Resource.LoadAssetAsync<TextAsset>(assetLocation,LoadMetadataAssetSuccess);
GameModule.Resource.LoadAsset<TextAsset>(assetLocation,LoadMetadataAssetSuccess);
}
m_LoadMetadataAssemblyWait = true;
}
@@ -247,27 +243,29 @@ namespace GameMain
/// <summary>
/// 加载元数据资源成功回调。
/// </summary>
/// <param name="assetOperationHandle">资源操作句柄。</param>
private unsafe void LoadMetadataAssetSuccess(AssetOperationHandle assetOperationHandle)
/// <param name="textAsset">代码资产。</param>
private unsafe void LoadMetadataAssetSuccess(TextAsset textAsset)
{
m_LoadMetadataAssetCount--;
string assetName = assetOperationHandle.AssetObject.name;
Log.Debug($"LoadMetadataAssetSuccess, assetName: [ {assetName} ]");
var textAsset = assetOperationHandle.AssetObject as TextAsset;
if (null == textAsset)
{
Log.Debug($"LoadMetadataAssetSuccess:Load text asset [ {assetName} ] failed.");
Log.Debug($"LoadMetadataAssetSuccess:Load Metadata failed.");
return;
}
string assetName = textAsset.name;
Log.Debug($"LoadMetadataAssetSuccess, assetName: [ {assetName} ]");
try
{
byte[] dllBytes = textAsset.bytes;
fixed (byte* ptr = dllBytes)
{
#if ENABLE_HYBRIDCLR
// 加载assembly对应的dll会自动为它hook。一旦Aot泛型函数的native函数不存在用解释器版本代码
HomologousImageMode mode = HomologousImageMode.SuperSet;
LoadImageErrorCode err = (LoadImageErrorCode)HybridCLR.RuntimeApi.LoadMetadataForAOTAssembly(dllBytes,mode);
Log.Warning($"LoadMetadataForAOTAssembly:{assetName}. mode:{mode} ret:{err}");
#endif
}
}
catch (Exception e)
@@ -279,8 +277,8 @@ namespace GameMain
finally
{
m_LoadMetadataAssemblyComplete = m_LoadMetadataAssemblyWait && 0 == m_LoadMetadataAssetCount;
}
GameModule.Resource.UnloadAsset(textAsset);
}
}
}

View File

@@ -16,41 +16,46 @@ namespace GameMain
{
private float _progress = 0f;
private Dictionary<string, bool> m_LoadedFlag = new Dictionary<string, bool>();
private readonly Dictionary<string, bool> _loadedFlag = new Dictionary<string, bool>();
public override bool UseNativeDialog => true;
private bool m_needProLoadConfig = false;
private readonly bool _needProLoadConfig = true;
/// <summary>
/// 预加载回调。
/// </summary>
private LoadAssetCallbacks m_PreLoadAssetCallbacks;
protected override void OnInit(ProcedureOwner procedureOwner)
{
base.OnInit(procedureOwner);
m_PreLoadAssetCallbacks = new LoadAssetCallbacks(OnPreLoadAssetSuccess, OnPreLoadAssetFailure);
}
private bool m_InitConfigXml = false;
protected override void OnEnter(ProcedureOwner procedureOwner)
{
base.OnEnter(procedureOwner);
m_LoadedFlag.Clear();
if (GameModule.Resource.PlayMode == EPlayMode.EditorSimulateMode)
{
m_InitConfigXml = true;
}
_loadedFlag.Clear();
UILoadMgr.Show(UIDefine.UILoadUpdate, Utility.Text.Format(LoadText.Instance.Label_Load_Load_Progress, 0));
GameEvent.Send("UILoadUpdate.RefreshVersion");
PreloadResources().Forget();
PreloadResources();
}
protected override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
{
base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
var totalCount = m_LoadedFlag.Count <= 0 ? 1 : m_LoadedFlag.Count;
var totalCount = _loadedFlag.Count <= 0 ? 1 : _loadedFlag.Count;
var loadCount = m_LoadedFlag.Count <= 0 ? 1 : 0;
var loadCount = _loadedFlag.Count <= 0 ? 1 : 0;
foreach (KeyValuePair<string, bool> loadedFlag in m_LoadedFlag)
foreach (KeyValuePair<string, bool> loadedFlag in _loadedFlag)
{
if (!loadedFlag.Value)
{
@@ -62,7 +67,7 @@ namespace GameMain
}
}
if (m_LoadedFlag.Count != 0)
if (_loadedFlag.Count != 0)
{
UILoadMgr.Show(UIDefine.UILoadUpdate, Utility.Text.Format(LoadText.Instance.Label_Load_Load_Progress, (float)loadCount / totalCount * 100));
}
@@ -87,11 +92,6 @@ namespace GameMain
return;
}
if (m_InitConfigXml == false)
{
return;
}
ChangeState<ProcedureLoadAssembly>(procedureOwner);
}
@@ -110,47 +110,50 @@ namespace GameMain
callback?.Invoke();
}
private async UniTaskVoid PreloadResources()
private void PreloadResources()
{
await SmoothValue(1f, 1.2f).ToUniTask(GameModule.Procedure);
await UniTask.Delay(TimeSpan.FromSeconds(2.5f));
if (m_needProLoadConfig)
if (_needProLoadConfig)
{
LoadAllConfig();
}
else
{
m_InitConfigXml = true;
}
}
private void LoadAllConfig()
{
if (GameModule.Resource.PlayMode == EPlayMode.EditorSimulateMode)
{
m_InitConfigXml = true;
return;
}
}
private void LoadConfig(string configName)
{
m_LoadedFlag.Add(configName, false);
GameModule.Resource.LoadAssetAsync<TextAsset>(configName, OnLoadSuccess);
}
private void OnLoadSuccess(AssetOperationHandle assetOperationHandle)
{
if (assetOperationHandle == null)
AssetInfo[] assetInfos = GameModule.Resource.GetAssetInfos("PRELOAD");
foreach (var assetInfo in assetInfos)
{
return;
PreLoad(assetInfo.Address);
}
#if UNITY_WEBGL
AssetInfo[] webAssetInfos = GameModule.Resource.GetAssetInfos("WEBGL_PRELOAD");
foreach (var assetInfo in webAssetInfos)
{
PreLoad(assetInfo.Address);
}
#endif
}
var name = assetOperationHandle.GetAssetInfo().Address;
m_LoadedFlag[name] = true;
Log.Info("Load config '{0}' OK.", name);
private void PreLoad(string location)
{
_loadedFlag.Add(location, false);
GameModule.Resource.LoadAssetAsync(location, typeof(UnityEngine.Object), m_PreLoadAssetCallbacks, null);
}
private void OnPreLoadAssetFailure(string assetName, LoadResourceStatus status, string errormessage, object userdata)
{
Log.Warning("Can not preload asset from '{0}' with error message '{1}'.", assetName, errormessage);
_loadedFlag[assetName] = true;
}
private void OnPreLoadAssetSuccess(string assetName, object asset, float duration, object userdata)
{
Log.Debug("Success preload asset from '{0}' duration '{1}'.", assetName, duration);
_loadedFlag[assetName] = true;
}
}
}

View File

@@ -10,11 +10,6 @@ namespace GameMain
{
public override bool UseNativeDialog => true;
protected override void OnEnter(ProcedureOwner procedureOwner)
{
base.OnEnter(procedureOwner);
}
protected override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
{
base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);

View File

@@ -35,6 +35,14 @@ namespace GameMain
//更新成功
//注意:保存资源版本号作为下次默认启动的版本!
operation.SavePackageVersion();
if (GameModule.Resource.PlayMode == EPlayMode.WebPlayMode ||
GameModule.Resource.UpdatableWhilePlaying)
{
// 边玩边下载还可以拓展首包支持。
ChangeState<ProcedurePreload>(procedureOwner);
return;
}
ChangeState<ProcedureCreateDownloader>(procedureOwner);
}
else

View File

@@ -22,7 +22,7 @@ namespace GameMain
base.OnEnter(procedureOwner);
UILoadMgr.Show(UIDefine.UILoadUpdate,$"更新静态版本文件...");
UILoadMgr.Show(UIDefine.UILoadUpdate, $"更新静态版本文件...");
//检查设备是否能够访问互联网
if (Application.internetReachability == NetworkReachability.NotReachable)
@@ -34,6 +34,7 @@ namespace GameMain
GetStaticVersion().Forget,
() => { ChangeState<ProcedureInitResources>(procedureOwner); });
}
UILoadMgr.Show(UIDefine.UILoadUpdate, LoadText.Instance.Label_RequestVersionIng);
// 用户尝试更新静态版本。
@@ -49,23 +50,35 @@ namespace GameMain
var operation = GameModule.Resource.UpdatePackageVersionAsync();
await operation.ToUniTask();
if (operation.Status == EOperationStatus.Succeed)
try
{
//线上最新版本operation.PackageVersion
GameModule.Resource.PackageVersion = operation.PackageVersion;
Log.Debug($"Updated package Version : from {GameModule.Resource.GetPackageVersion()} to {operation.PackageVersion}");
ChangeState<ProcedureUpdateManifest>(_procedureOwner);
}
else
{
Log.Error(operation.Error);
await operation.ToUniTask();
UILoadTip.ShowMessageBox($"用户尝试更新静态版本失败!点击确认重试 \n \n <color=#FF0000>原因{operation.Error}</color>", MessageShowType.TwoButton,
LoadStyle.StyleEnum.Style_Retry
, () => { ChangeState<ProcedureUpdateVersion>(_procedureOwner); }, UnityEngine.Application.Quit);
if (operation.Status == EOperationStatus.Succeed)
{
//线上最新版本operation.PackageVersion
GameModule.Resource.PackageVersion = operation.PackageVersion;
Log.Debug($"Updated package Version : from {GameModule.Resource.GetPackageVersion()} to {operation.PackageVersion}");
ChangeState<ProcedureUpdateManifest>(_procedureOwner);
}
else
{
OnGetStaticVersionError(operation.Error);
}
}
catch (Exception e)
{
OnGetStaticVersionError(e.Message);
}
}
private void OnGetStaticVersionError(string error)
{
Log.Error(error);
UILoadTip.ShowMessageBox($"用户尝试更新静态版本失败!点击确认重试 \n \n <color=#FF0000>原因{error}</color>", MessageShowType.TwoButton,
LoadStyle.StyleEnum.Style_Retry
, () => { ChangeState<ProcedureUpdateVersion>(_procedureOwner); }, UnityEngine.Application.Quit);
}
}
}

View File

@@ -1,14 +1,49 @@
fileFormatVersion: 2
guid: 5651992cdad94894a3af7dc3f1da9170
timeCreated: 1488828285
PluginImporter:
serializedVersion: 1
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
Any:
- first:
: N3DS
second:
enabled: 1
settings: {}
- first:
: PSM
second:
enabled: 1
settings: {}
- first:
: PSP2
second:
enabled: 1
settings: {}
- first:
: SamsungTV
second:
enabled: 1
settings: {}
- first:
: Tizen
second:
enabled: 1
settings: {}
- first:
: WiiU
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings:
Exclude Android: 1
@@ -33,45 +68,46 @@ PluginImporter:
Exclude XboxOne: 0
Exclude iOS: 0
Exclude tvOS: 0
Editor:
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
N3DS:
- first:
PS4: PS4
second:
enabled: 1
settings: {}
PS4:
- first:
Standalone: Win64
second:
enabled: 1
settings: {}
PSM:
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
PSP2:
enabled: 1
settings: {}
SamsungTV:
enabled: 1
settings: {}
Tizen:
enabled: 1
settings: {}
WebGL:
enabled: 1
settings: {}
WiiU:
enabled: 1
settings: {}
WindowsStoreApps:
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 1
settings:
CPU: AnyCPU
XboxOne:
- first:
XboxOne: XboxOne
second:
enabled: 1
settings: {}
iOS:
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
tvOS:
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:

View File

@@ -1,14 +1,49 @@
fileFormatVersion: 2
guid: 5978f8f3dd274e848fbb7a123bde1fb9
timeCreated: 1488828285
PluginImporter:
serializedVersion: 1
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
Any:
- first:
: N3DS
second:
enabled: 1
settings: {}
- first:
: PSM
second:
enabled: 1
settings: {}
- first:
: PSP2
second:
enabled: 1
settings: {}
- first:
: SamsungTV
second:
enabled: 1
settings: {}
- first:
: Tizen
second:
enabled: 1
settings: {}
- first:
: WiiU
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings:
Exclude Android: 1
@@ -33,45 +68,46 @@ PluginImporter:
Exclude XboxOne: 0
Exclude iOS: 0
Exclude tvOS: 0
Editor:
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
N3DS:
- first:
PS4: PS4
second:
enabled: 1
settings: {}
PS4:
- first:
Standalone: Win64
second:
enabled: 1
settings: {}
PSM:
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
PSP2:
enabled: 1
settings: {}
SamsungTV:
enabled: 1
settings: {}
Tizen:
enabled: 1
settings: {}
WebGL:
enabled: 1
settings: {}
WiiU:
enabled: 1
settings: {}
WindowsStoreApps:
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 1
settings:
CPU: AnyCPU
XboxOne:
- first:
XboxOne: XboxOne
second:
enabled: 1
settings: {}
iOS:
- first:
iPhone: iOS
second:
enabled: 1
settings: {}
tvOS:
- first:
tvOS: tvOS
second:
enabled: 1
settings: {}
userData:

View File

@@ -1,17 +1,49 @@
fileFormatVersion: 2
guid: d2a8f0021d6b47c5923d8972dfb81ef1
timeCreated: 1488828285
PluginImporter:
serializedVersion: 1
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
Android:
- first:
: Linux
second:
enabled: 1
settings: {}
Any:
- first:
: LinuxUniversal
second:
enabled: 1
settings: {}
- first:
: OSXIntel
second:
enabled: 1
settings: {}
- first:
: OSXIntel64
second:
enabled: 1
settings: {}
- first:
: PSM
second:
enabled: 0
settings: {}
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings:
Exclude Android: 0
@@ -36,38 +68,39 @@ PluginImporter:
Exclude XboxOne: 1
Exclude iOS: 1
Exclude tvOS: 1
Editor:
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
Linux:
- first:
Standalone: Linux64
second:
enabled: 1
settings: {}
Linux64:
settings:
CPU:
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings: {}
LinuxUniversal:
settings:
CPU:
- first:
Standalone: Win
second:
enabled: 1
settings: {}
OSXIntel:
enabled: 1
settings: {}
OSXIntel64:
enabled: 1
settings: {}
OSXUniversal:
enabled: 1
settings: {}
PSM:
settings:
CPU:
- first:
Standalone: Win64
second:
enabled: 0
settings: {}
Win:
enabled: 1
settings: {}
Win64:
enabled: 1
settings: {}
WindowsStoreApps:
settings:
CPU:
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU

View File

@@ -1,17 +1,49 @@
fileFormatVersion: 2
guid: 1e0a9643dc0d4b46bf2321f72c4e503e
timeCreated: 1488828285
PluginImporter:
serializedVersion: 1
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
Android:
- first:
: Linux
second:
enabled: 1
settings: {}
Any:
- first:
: LinuxUniversal
second:
enabled: 1
settings: {}
- first:
: OSXIntel
second:
enabled: 1
settings: {}
- first:
: OSXIntel64
second:
enabled: 1
settings: {}
- first:
: PSM
second:
enabled: 0
settings: {}
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings:
Exclude Android: 0
@@ -36,38 +68,39 @@ PluginImporter:
Exclude XboxOne: 1
Exclude iOS: 1
Exclude tvOS: 1
Editor:
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
Linux:
- first:
Standalone: Linux64
second:
enabled: 1
settings: {}
Linux64:
settings:
CPU:
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings: {}
LinuxUniversal:
settings:
CPU:
- first:
Standalone: Win
second:
enabled: 1
settings: {}
OSXIntel:
enabled: 1
settings: {}
OSXIntel64:
enabled: 1
settings: {}
OSXUniversal:
enabled: 1
settings: {}
PSM:
settings:
CPU:
- first:
Standalone: Win64
second:
enabled: 0
settings: {}
Win:
enabled: 1
settings: {}
Win64:
enabled: 1
settings: {}
WindowsStoreApps:
settings:
CPU:
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU

Some files were not shown because too many files have changed in this diff Show More