Skip to content

Commit

Permalink
更新hotreload不支持的特性
Browse files Browse the repository at this point in the history
  • Loading branch information
pirunxi committed Jul 11, 2024
1 parent c52fa90 commit 28969f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions docs/business/reload/hotreloadassembly.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
- MonoBehaviour和ScriptableObject相关
- 要求重载的MonoBehaviour中的事件或消息函数如Awake、OnEable之类不发生增删(但函数体可以变化)
- 要求重载后在旧Assembly中存在同名脚本类的序列化字段名不发生变化(类型可以变)
- 如果字段类型为可卸载程序集中的自定义类型A(class或struct或enum),必须给它加上`[Serializable]`特性
- 不支持字段类型为`List<A>`其中A为可卸载的程序集中的类型,请替换为`A[]`
- 不能继承泛型类型,例如`class MyScript : CommonScript<int>`
- 一些会缓存反射信息的库(这种行为在序列化相关的库中最为普遍,如LitJson),在热重载后需要清理掉缓存的反射信息
- 不支持析构函数,~XXX()。也不允许实例化泛型参数带本程序集类型的带析构函数的泛型类
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ Hot reload technology is used to completely unload or reload an assembly, suitab

## Unsupported Features and Special Requirements

- Business code must stop using objects or functions from the unloaded assembly and exit all old logic being executed.
- Cannot directly unload dependent assemblies; dependencies must be unloaded first in reverse dependency order before unloading the dependent assemblies. For example, if A.dll depends on B.dll, then A.dll must be unloaded first before unloading B.dll.
- MonoBehaviour and ScriptableObject related:
- Events or message functions in reloaded MonoBehaviours such as Awake, OnEnable, etc., should not be added or removed (but the function body can change).
- After reloading, the serialized field names of the same-named script classes in the old assembly must not change (but the types can change).
- Cannot inherit generic types, such as `class MyScript: CommonScript<int>`.
- Some libraries that cache reflection information (this behavior is most common in serialization-related libraries like LitJson) need to clear the cached reflection information after hot reload.
- Does not support destructors, ~XXX(). Also, does not allow instantiating generic classes with destructor functions that belong to the generic parameters of this assembly.
- Not compatible with DOTS. Due to DOTS caching a large amount of type information and its complex implementation, it is difficult to clean up cached information separately.
- Ensure that the business code no longer uses objects or functions from the unloaded Assembly and exits all executing old logic.
- You cannot directly unload a dependent Assembly; you must unload the dependents before the dependencies in reverse dependency order. For example, if A.dll depends on B.dll, you need to unload A.dll first, then B.dll.
- Related to MonoBehaviour and ScriptableObject:
- Ensure that overloaded MonoBehaviour event or message functions like Awake and OnEnable are not added or removed (but the function body can change).
- Ensure that the serialized field names in the script classes with the same name in the old Assembly do not change (the types can change).
- If the field type is a custom type A (class, struct, or enum) from an unloadable Assembly, it must be marked with the `[Serializable]` attribute.
- Field types such as `List&lt;A&gt;`, where A is a type from an unloadable Assembly, are not supported; replace them with `A[]`.
- Generic types cannot be inherited, e.g., `class MyScript : CommonScript<int>`.
- Some libraries that cache reflection information (most common in serialization-related libraries like LitJson) need to clear cached reflection information after hot reload.
- Destructors `~XXX()` are not supported. Instantiating generic classes with destructors where the generic parameter is a type from the current Assembly is also not allowed.
- Incompatible with DOTS. Due to the extensive caching of type information and the complexity of implementation, it is difficult to individually clear the cached information.


## Incompatible Libraries

Expand Down

0 comments on commit 28969f5

Please sign in to comment.