Skip to content

Commit 61c2aa3

Browse files
committed
更新文档
1 parent 3d08cd8 commit 61c2aa3

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

docs/beginner/monobehaviour.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public class Print : MonoBehaviour
2323
}
2424
```
2525

26+
## 解决GameObject被裁剪的问题
27+
28+
由于快速上手中完全没有用到GameObject,导致GameObject类型的部分函数在打包时被裁剪。`HybridCLR/Generate/All`命令会重新扫描热更新程序集,生成link.xml以保留热更新代码中用到的类型。
29+
30+
请运行完该命令后**重新构建一次新包**,否则运行下一步的热更新代码时会出现`GameObject::.ctor`函数找不到的错误。
31+
32+
2633
## 代码中调用AddComponent来动态挂载热更新脚本
2734

2835
修改 `Hello.Run`函数,添加动态挂载Print脚本的代码,最终代码如下:
@@ -51,3 +58,4 @@ public class Print : MonoBehaviour
5158

5259
对于新手来说,你只需要记住:挂载热更新脚本的资源(场景或prefab)必须打包成ab,在实例化资源前先加载热更新dll即可(这个要求是显然的!)。
5360

61+

i18n/en/docusaurus-plugin-content-docs/current/beginner/monobehaviour.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public class Print : MonoBehaviour
2424
}
2525
```
2626

27+
## Solve issue of GameObject being stripped
28+
29+
Since GameObject is not used at all in the quick start, some functions of the GameObject type are stripped when building. The `HybridCLR/Generate/All` command will rescan the hot update assembly and generate link.xml to retain the types used in the hot update code.
30+
31+
Please **rebuild a new package** after running this command, otherwise the error `GameObject::.ctor` function cannot be found will appear when running the next hot update code.
32+
2733
## Call AddComponent in the code to dynamically mount the hot update script
2834

2935
Modify the `Hello.Run` function and add the code to dynamically mount the Print script. The final code is as follows:

0 commit comments

Comments
 (0)