注:部分聊天记录如果观点有误那也莫得办法, 请及时提醒更正, 方便新人理解.
首先要区分服务器热更和客户端热更
客户端热更在ET5.0(包括)以前是使用ILRuntime热更的.
服务器端与客户端不同。服务器端的ETHotfix只有逻辑,没有数据。数据被放在ETModel中,所以服务器端可以在运行时重新加载修复DLL。客户端热更新是因为ios不允许Unity加载DLL。它需要使用一个ILRuntime库来执行ETHotfix,所以客户端热更新需要用数据和逻辑重新启动。ILRuntime,你可以认为是一种C#语法语言,用来绕过ios不能加载DLLS的限制
Model层和Hotfix层交互
大空忆(535421993)
学习Et的一点总结:
- 关于跨域交互:Model2Hotfix 使用事件,Hotfix2Moedel使用引用。
- 关于跨层交互:View2Data使用引用,Data2View使用引用。(因为是在同一组件内,所以互相都有对方的引用。 )
熊猫 2020/4/17
最好只从hotfix调用mono。如果实在要用就抛个事件,hotfix可以订阅mono层的事件


Ray 15:43:30
- 服务端对于正在update的模块..热更会导致什么结果?
- 热更后走的逻辑是新的还是旧的..?
- 包括在start()里while+wait固定时长的逻辑..应该是什么结果..?
【群主】熊猫(80081771) 15:57:25
@RAY update会走新的逻辑。协程没有结束会走旧的,结束重新开协程会走新的
所以while await这种是不能热更的,要在load中取消这个协程然后重新创建新的协程才能更新逻辑

ETModel vs ETHotfix
afonsolage:
ETModel vs ETHotfix
Hello guys,
I’m getting confused about when to add code on ETModel vs ETHotfix. I saw some classes that exists in both ETModel and ETHotfix and they are the same. Also, there are two Game.Scenes, one for ETHotfix and another for ETModel.
At first I tought ETHotfix will have only logic, no data, so I would add on it only Handlers, Systems and Helpers, but when reading some sources, I saw some components on ETHotfix also.
There is some general golden rule to when add code on ETModel vs ETHotfix?
我对何时在ETModel vs ETHotfix上添加代码感到困惑。我在ETModel和ETHotfix中都看到了一些类,它们是相同的。此外,还有两个 Game.Scenes,一个为ETHotfix,一个为ETModel。
起初,我认为ETHotfix只有逻辑,没有数据,所以我只会在上面添加Handlers、Systems 和Helpers,但是当阅读一些源代码时,我也看到了ETHotfix上的一些components。
在ETModel vs ETHotfix上添加代码时,有一些通用的黄金法则?
浪里个浪:
Anything needs to update anytime after the game released , use ETHotfix.
But I like ETModel, so I almost add code using ETModel. Maybe I will modify them after the core gameplay has done.
ETHotfix can use ETModel’s class or function without limit , Just “using ETModel” at head position.
ETModel can’t use ETHotfix’s class or funcion ,so u need to use the [Event(EventIdType.xxxx)] to tell ETHotfix what to do.
游戏发布后任何需要更新的东西,用ETHotfix。
但是我喜欢ETModel,所以几乎是用ETModel添加代码。也许我会在核心游戏完成后修改它们。
ETHotfix可以无限制地使用ETModel的类或函数,只需在头部位置“使用ETModel”即可。
ETModel不能使用ETHotfix的类或函数,所以您需要使用[Event(EventIdType.xxxx)]来告诉ETHotfix该做什么。
egametang:
The client side is different from the server side. The server side ETHotfix has only logic and no data. The data is placed in the ETModel, so the server side can reload the hotfix DLL at runtime. The client hot update is because ios does not allow Unity to load the DLL. It needs to use an ILRuntime library to perform ETHotfix, so the client hot update needs to be restarted with both data and logic. ILRuntime, which you can think of as a C# syntactic language, is used to get around the limitation that ios can’t load DLLS
ILRuntime lib https://github.com/Ourpalm/ILRuntime
客户端与服务器端不同。服务器端的ETHotfix只有逻辑,没有数据。数据被放在ETModel中,所以服务器端可以在运行时重新加载修复DLL。客户端热更新是因为ios不允许Unity加载DLL。它需要使用一个ILRuntime库来执行ETHotfix,所以客户端热更新需要用数据和逻辑重新启动。ILRuntime,你可以认为是一种C#语法语言,用来绕过ios不能加载DLLS的限制
afonsolage:
Understood, so the “Golden Rule” is ETHotfix is volatile while ETModel isn’t. When adding classes, all data (Entity and Components) should be added to ETModel, while logic (Systems, Handlers and Helpers) should be added to ETHotfix. On runtime, when adding components to Scenes, I should add to ETHotfix.Game.Scene only components that isn’t senstive to game, like cache components or other components that can be rebuilt when Hotfix.dll got reload on runtime.
But this rule only apply to Server, on Client it’s mixed up. So on client should I follow 浪里个浪 tip? About adding things on ETModel until the game core is done and later on add more “volatile” systems on ETHotfix.
Anyway, thanks for the help guys!
明白了,所以“黄金法则”是: ETHotfix是易变的,而ETModel不是。添加类时,所有数据(Entity 和Components)都应该添加到ETModel中,而逻辑(Systems, Handlers 和Helpers)应该添加到ETHotfix中。在运行时,当添加组件到场景时,我应该添加到ETHotfix.Game.Scene只有对游戏不敏感的组件,比如缓存组件或者其他可以在Hotfix.dll运行时重新加载时重建的组件。
但是这个规则只适用于服务器,在客户端它是混合的。所以在客户端应该是 "浪里个浪"提示的这样吗? 。关于在ETModel上添加东西,直到游戏核心完成,然后在ETHotfix上添加更多“不稳定”的系统。
不管怎样,谢谢你们的帮助!
egametang:
On the server side, you’d better put all the methods in ETHotfix. The methods in the class are called extension methods and put them in ETHotfix so that they can be updated at runtime.
在服务器端,最好把所有的方法都放在ETHotfix里。类中的方法被称为扩展方法,并将它们放入ETHotfix中,以便它们可以在运行时更新。