Files
netease-bedrock-wiki/mconline/20-玩法地图教程/第09章:DEBUG你的地图玩法并进行自测/课程01.常规的Python报错处理.md
2025-08-25 18:36:29 +08:00

47 lines
1.8 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://nie.res.netease.com/r/pic/20210730/ee109f39-8987-46e0-9fe7-40ebb23060fa.png
hard: 进阶
time: 20分钟
---
# 使用编辑器的开发测试功能
<iframe src="https://cc.163.com/act/m/daily/iframeplayer/?id=6152bac9b647e504b523d39c" height="600" width="800" allow="fullscreen" />
在开发的过程中,免不了发生各种奇怪的问题,而为了解决这些问题,我们需要先发现他们;在编辑器的作品框中有开发测试功能,我们可以点击进入到游戏中测试。
![1](./images/1.png)
与游戏一起打开的还有脚本测试日志窗口通过这个我们可以得到很多反馈进而帮助我们判断问题。在开发测试的过程中密切关注日志可以第一时间发现并解决BUG。
![2](./images/2.png)
## 常规的Python报错处理
在python文件发生错误的时候日志通常会发生报错我们可以根据报错来排查和解决问题。
这是一个常规的python报错倒数第二行报错已经指出了问题所在在404行的Create_Shop_UI函数中最后一行也提示了问题属性错误FarmClientSystem工程中没有属性furniture_shop_item_button_tex
![3](./images/3.png)
于是我们找到FarmClientSystem中的Create_Shop_UI函数
```python
class FarmClientSystem(ClientSystem):
def __init__(self, namespace, systemName):
super(FarmClientSystem, self).__init__(namespace, systemName)
self.furniture_shop_item_button_text = [
#···
]
# ···
def Create_Shop_UI(self,event):
# ···
# 404行,furniture_shop_item_button_text变量的名字写错(少了一个t)
self.ui.item_button_text = self.furniture_shop_item_button_tex
```
根据这个规律来排查问题常规的python报错都可以很快的解决