- Creator 版本: 3.4.2
@ccclass('Hello')
export class Hello extends Component
{
constructor()
{
super();
// 不应该无限重复执行
this.scheduleOnce(()=>console.log("test"));
// 根据源码判断, 是因为 此时的 this._id !== 反序列化后的 _id
// 导致 scheduler 执行后无法找到对应的 target 来取消
}
}
我知道在生命周期方法中调用是正常的,
请问在 constructor 中 schedule 是否是被允许的情况 ?
如果不允许, 引擎是否应该 检测 & throw ?