fix: 修复组件销毁时事件解绑和空引用问题并添加任务界面
- 在多个组件的onDestroy方法中添加节点有效性检查,防止无效节点上解绑事件 - 修复MissionComp中任务启动逻辑,改为通过UI打开方式触发MissionStart事件 - 添加新的任务界面(UIID.Mission)及相关配置 - 修复MissionCardComp中Map未初始化导致的空引用问题 - 优化按钮事件绑定和解绑逻辑,增加空值检查
This commit is contained in:
@@ -182,13 +182,13 @@ export class SkillView extends CCComp {
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
// 清理碰撞体事件监听
|
||||
if (this.collider) {
|
||||
if (this.collider && this.collider.isValid) {
|
||||
this.collider.off(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
this.collider.enabled = false;
|
||||
}
|
||||
this.pendingDisableCollider = false;
|
||||
this.isDisposing = false;
|
||||
if (this.anim) {
|
||||
if (this.anim && this.anim.isValid) {
|
||||
this.anim.off(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||
}
|
||||
// 取消所有定时器
|
||||
|
||||
@@ -16,8 +16,9 @@ export class oneCom extends Component {
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
if (!this.anim) return;
|
||||
this.anim.off(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||
if (this.anim && this.anim.isValid) {
|
||||
this.anim.off(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||
}
|
||||
this.anim = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user