Files
netease-modsdk-wiki/docs/mconline/10-addon教程/第16章:创建界面/课程03.在游戏内弹出界面.md
boybook 760c2dd9ad 2.6
2025-12-01 20:59:16 +08:00

31 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
front: https://mc.res.netease.com/pc/zt/20201109161633/mc-dev/assets/img/3_1.7d892d10.jpg
hard: 进阶
time: 15分钟
---
# 在游戏内弹出界面
#### 作者:境界
①切换回关卡编辑器,在资源管理器面板下,选择行为包,右键打开行为包所在的文件夹。在文件夹内新建一个脚本文件夹工程。 
②由于UI界面运行在客户端并且界面功能仅需调用客户端接口因此我们只注册一个客户端系统。
③新建一个CustomUi.py文件导入ScreenNode类。新增一个Main类并继承ScreenNode。
![](./images/3_2.jpg)
④监听UiInitFinished事件在回调函数内使用注册UI接口UI必须注册才能创建。其中第一个参数是命名空间第二个参数是UI名称第三个参数是ui节点路径。ui节点路径的格式与注册系统类似即"脚本文件夹.CustomUi.Main"。第四个是ui json文件入口即"custom_ui.main"。
![](./images/3_1.jpg)
⑤使用客户端的PushScreen接口第一个参数即UI的命名空间第二个参数即UI名称分别对应注册UI的前两个参数。进入游戏后查看效果。