fix: 修复组件销毁时事件解绑和空引用问题并添加任务界面
- 在多个组件的onDestroy方法中添加节点有效性检查,防止无效节点上解绑事件 - 修复MissionComp中任务启动逻辑,改为通过UI打开方式触发MissionStart事件 - 添加新的任务界面(UIID.Mission)及相关配置 - 修复MissionCardComp中Map未初始化导致的空引用问题 - 优化按钮事件绑定和解绑逻辑,增加空值检查
This commit is contained in:
@@ -513,12 +513,18 @@ export class CardComp extends CCComp {
|
||||
|
||||
/** 解绑触控,防止节点销毁后残留回调 */
|
||||
private unbindEvents() {
|
||||
this.node.off(NodeEventType.TOUCH_START, this.onCardTouchStart, this);
|
||||
this.node.off(NodeEventType.TOUCH_MOVE, this.onCardTouchMove, this);
|
||||
this.node.off(NodeEventType.TOUCH_END, this.onCardTouchEnd, this);
|
||||
this.node.off(NodeEventType.TOUCH_CANCEL, this.onCardTouchCancel, this);
|
||||
this.Lock?.off(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
||||
this.unLock?.off(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
||||
if (this.node && this.node.isValid) {
|
||||
this.node.off(NodeEventType.TOUCH_START, this.onCardTouchStart, this);
|
||||
this.node.off(NodeEventType.TOUCH_MOVE, this.onCardTouchMove, this);
|
||||
this.node.off(NodeEventType.TOUCH_END, this.onCardTouchEnd, this);
|
||||
this.node.off(NodeEventType.TOUCH_CANCEL, this.onCardTouchCancel, this);
|
||||
}
|
||||
if (this.Lock && this.Lock.isValid) {
|
||||
this.Lock.off(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
||||
}
|
||||
if (this.unLock && this.unLock.isValid) {
|
||||
this.unLock.off(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
||||
}
|
||||
}
|
||||
|
||||
// ======================== 触摸交互 ========================
|
||||
|
||||
Reference in New Issue
Block a user