From 87affc076d6f2fdbc4ff2f10a11d06ac7e4141d8 Mon Sep 17 00:00:00 2001 From: zheng han Date: Fri, 8 Jan 2021 14:34:19 +0800 Subject: [PATCH] add type for Prefab related classes (#8100) * add types info * fix type mistake Co-authored-by: Santy-Wang --- cocos/core/utils/prefab-utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cocos/core/utils/prefab-utils.ts b/cocos/core/utils/prefab-utils.ts index bea75264e0..367ea95a13 100644 --- a/cocos/core/utils/prefab-utils.ts +++ b/cocos/core/utils/prefab-utils.ts @@ -29,7 +29,7 @@ * @hidden */ -import { ccclass, serializable, editable } from 'cc.decorator'; +import { ccclass, serializable, editable, type } from 'cc.decorator'; import { EDITOR, SUPPORT_JIT } from 'internal:constants'; import { legacyCC } from '../global-exports'; import { Prefab } from '../assets'; @@ -92,6 +92,7 @@ export class TargetInfo { @ccclass('CCPropertyOverrideInfo') export class PropertyOverrideInfo { @serializable + @type(TargetInfo) public targetInfo: TargetInfo|null = null; @serializable public propertyPath: string[] = []; @@ -110,8 +111,10 @@ export class PropertyOverrideInfo { @ccclass('cc.MountedChildrenInfo') export class MountedChildrenInfo { @serializable + @type(TargetInfo) public targetInfo: TargetInfo|null = null; @serializable + @type([legacyCC.Node]) public nodes: Node[] = []; // eslint-disable-next-line consistent-return @@ -133,17 +136,21 @@ export class PrefabInstance { // 记录PrefabInstance所属的Prefab的Root节点信息 @serializable + @type(legacyCC.Node) public prefabRootNode?: Node; // 实例化的Prefab中额外增加的子节点数据 @serializable + @type([MountedChildrenInfo]) public mountedChildren: MountedChildrenInfo[] = []; // 属性的覆盖数据 @serializable + @type([PropertyOverrideInfo]) public propertyOverrides: PropertyOverrideInfo[] = []; @serializable + @type([TargetInfo]) public removedComponents: TargetInfo[] = []; // eslint-disable-next-line consistent-return @@ -300,6 +307,7 @@ export function applyMountedChildren (node: Node, mountedChildren: MountedChildr target._children.push(childNode); // @ts-expect-error private member access childNode._parent = target; + // siblingIndex update is in _onBatchCreated function, and it needs a parent. childNode._onBatchCreated(false); } }