From aa7ff8af0bcfb9ae16d5c3dfd9cf02b899b9221b Mon Sep 17 00:00:00 2001 From: GengineJS <476393671@qq.com> Date: Mon, 26 Jul 2021 11:19:35 +0800 Subject: [PATCH] Support native nodes to set parent to null (#9066) --- cocos/core/scene-graph/node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/core/scene-graph/node.ts b/cocos/core/scene-graph/node.ts index 2290500626..059117a0a1 100644 --- a/cocos/core/scene-graph/node.ts +++ b/cocos/core/scene-graph/node.ts @@ -529,7 +529,7 @@ export class Node extends BaseNode implements CustomSerializable { if (keepWorldTransform) { this.updateWorldTransform(); } super.setParent(value, keepWorldTransform); if (JSB) { - this._nativeObj!.setParent(this.parent?.native); + this._nativeObj!.setParent(this.parent ? this.parent.native : null); } }