-
Creator 版本:3.8.8
-
目标平台: web
-
重现方式:
-
首个报错:
-
之前哪个版本是正常的:
-
手机型号:
-
手机浏览器:
-
编辑器操作系统:
-
重现概率: 100%重现
import { _decorator, CircleCollider2D, Component, Contact2DType, instantiate, Node, Prefab } from ‘cc’;
const { ccclass, property } = _decorator;
@ccclass(‘main’)
export class main extends Component {
@property(Prefab)
pfb: Prefab = null;
@property(Node)
colliderItem: Node = null;
start() {
const collider = this.colliderItem.getComponent(CircleCollider2D);
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
}
onBeginContact() {
let nd = instantiate(this.pfb);
nd.parent = this.node.parent;
}
}
在刚体监听帧中创建新节点,只要设置父节点,就会报错

延迟一帧设置就没问题
this.scheduleOnce(() => {
nd.parent = this.node.parent;
});
这个是Bug还是特性?
因为实际项目非常复杂,这块又是底层的逻辑,不想做大的改动,。
所以请教一下,有没有别的方法解决?