fix: 修复组件销毁时事件解绑和空引用问题并添加任务界面
- 在多个组件的onDestroy方法中添加节点有效性检查,防止无效节点上解绑事件 - 修复MissionComp中任务启动逻辑,改为通过UI打开方式触发MissionStart事件 - 添加新的任务界面(UIID.Mission)及相关配置 - 修复MissionCardComp中Map未初始化导致的空引用问题 - 优化按钮事件绑定和解绑逻辑,增加空值检查
This commit is contained in:
@@ -78,10 +78,10 @@ export class TalentsComp extends CCComp {
|
||||
|
||||
protected onLoad(): void {
|
||||
// 绑定按钮事件
|
||||
if (this.btn_reset) {
|
||||
if (this.btn_reset && this.btn_reset.node) {
|
||||
this.btn_reset.node.on(Button.EventType.CLICK, this.onResetClicked, this);
|
||||
}
|
||||
if (this.btn_close) {
|
||||
if (this.btn_close && this.btn_close.node) {
|
||||
this.btn_close.node.on(Button.EventType.CLICK, this.onCloseClicked, this);
|
||||
}
|
||||
}
|
||||
@@ -343,6 +343,12 @@ export class TalentsComp extends CCComp {
|
||||
|
||||
protected onDestroy(): void {
|
||||
mLogger.log(this.debugMode, 'TalentsComp', "释放界面");
|
||||
if (this.btn_reset && this.btn_reset.node && this.btn_reset.node.isValid) {
|
||||
this.btn_reset.node.off(Button.EventType.CLICK, this.onResetClicked, this);
|
||||
}
|
||||
if (this.btn_close && this.btn_close.node && this.btn_close.node.isValid) {
|
||||
this.btn_close.node.off(Button.EventType.CLICK, this.onCloseClicked, this);
|
||||
}
|
||||
}
|
||||
|
||||
/** ECS 组件移除时销毁节点 */
|
||||
|
||||
Reference in New Issue
Block a user