Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3.8.6] Inline enums for CCObjectFlags. #18190

Merged
merged 7 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cocos/2d/components/rich-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { ccclass, executeInEditMode, executionOrder, help, menu, multiline, type
import { DEBUG, DEV, EDITOR } from 'internal:constants';
import { Font, SpriteAtlas, TTFFont, SpriteFrame } from '../assets';
import { EventTouch } from '../../input/types';
import { assert, warnID, Color, Vec2, CCObject, cclegacy, js, Size } from '../../core';
import { assert, warnID, Color, Vec2, CCObjectFlags, cclegacy, js, Size } from '../../core';
import { HtmlTextParser, IHtmlTextParserResultObj, IHtmlTextParserStack } from '../utils/html-text-parser';
import { Node } from '../../scene-graph';
import { CacheMode, HorizontalTextAlignment, Label, VerticalTextAlignment } from './label';
Expand Down Expand Up @@ -103,7 +103,7 @@ function getSegmentByPool (type: string, content: string | SpriteFrame): ISegmen
if (!node) {
node = new Node(type);
}
node.hideFlags |= CCObject.Flags.DontSave | CCObject.Flags.HideInHierarchy;
node.hideFlags |= CCObjectFlags.DontSave | CCObjectFlags.HideInHierarchy;
node.active = true; // Reset node state when use node
if (type === RichTextChildImageName) {
seg.comp = node.getComponent(Sprite) || node.addComponent(Sprite);
Expand Down
10 changes: 5 additions & 5 deletions cocos/3d/reflection-probe/reflection-probe-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
import { ccclass, executeInEditMode, help, menu, playOnFocus, serializable, tooltip, type, visible } from 'cc.decorator';
import { EDITOR, EDITOR_NOT_IN_PREVIEW } from 'internal:constants';
import { CCBoolean, CCObject, Color, screen, Enum, Vec3, warn } from '../../core';
import { CCBoolean, Color, screen, Enum, Vec3, warn, CCObjectFlags } from '../../core';

import { TextureCube } from '../../asset/assets';
import { scene } from '../../render-scene';
Expand Down Expand Up @@ -145,15 +145,15 @@
}
this.probe.switchProbeType(value, null);
if (EDITOR) {
this._objFlags |= CCObject.Flags.IsRotationLocked;
this._objFlags |= CCObjectFlags.IsRotationLocked;
}
ReflectionProbeManager.probeManager.clearPlanarReflectionMap(this.probe);
} else {
if (lastSizeIsNoExist) {
this._size.set(ReflectionProbe.DEFAULT_PLANER_SIZE);
}
if (EDITOR && this._objFlags & CCObject.Flags.IsRotationLocked) {
this._objFlags ^= CCObject.Flags.IsRotationLocked;
if (EDITOR && this._objFlags & CCObjectFlags.IsRotationLocked) {
this._objFlags ^= CCObjectFlags.IsRotationLocked;
}
if (!this._sourceCamera) {
warn('the reflection camera is invalid, please set the reflection camera');
Expand All @@ -176,7 +176,7 @@
* @en set render texture size
* @zh 设置渲染纹理大小
*/
@visible(function (this: ReflectionProbe) { return this.probeType === ProbeType.CUBE; })

Check warning on line 179 in cocos/3d/reflection-probe/reflection-probe-component.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@type(Enum(ProbeResolution))
set resolution (value: number) {
this._resolution = value;
Expand All @@ -192,7 +192,7 @@
* @zh 相机的缓冲清除标志位,指定帧缓冲的哪部分要每帧清除。
*/
@type(Enum(ProbeClearFlag))
@visible(function (this: ReflectionProbe) { return this.probeType === ProbeType.CUBE; })

Check warning on line 195 in cocos/3d/reflection-probe/reflection-probe-component.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
set clearFlag (value: number) {
this._clearFlag = value;
this.probe.clearFlag = this._clearFlag;
Expand All @@ -205,7 +205,7 @@
* @en Clearing color of the camera.
* @zh 相机的颜色缓冲默认值。
*/
@visible(function (this: ReflectionProbe) { return this._clearFlag === ProbeClearFlag.SOLID_COLOR && this.probeType === ProbeType.CUBE; })

Check warning on line 208 in cocos/3d/reflection-probe/reflection-probe-component.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@type(Color)
set backgroundColor (val: Color) {
this._backgroundColor = val;
Expand Down Expand Up @@ -233,7 +233,7 @@
* @en The camera to render planar reflections, specified by the user
* @zh 需要渲染平面反射的相机,由用户指定
*/
@visible(function (this: ReflectionProbe) { return this.probeType === ProbeType.PLANAR; })

Check warning on line 236 in cocos/3d/reflection-probe/reflection-probe-component.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@type(Camera)
set sourceCamera (camera: Camera) {
this._sourceCamera = camera;
Expand All @@ -254,7 +254,7 @@
* @en fast bake no convolution.
* @zh 快速烘焙不会进行卷积。
*/
@visible(function (this: ReflectionProbe) { return this.probeType === ProbeType.CUBE; })

Check warning on line 257 in cocos/3d/reflection-probe/reflection-probe-component.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@type(CCBoolean)
@tooltip('i18n:reflection_probe.fastBake')
get fastBake (): boolean {
Expand Down Expand Up @@ -426,7 +426,7 @@
this._probe = new scene.ReflectionProbe(this._probeId);
if (this._probe) {
const cameraNode = new Node('ReflectionProbeCamera');
cameraNode.hideFlags |= CCObject.Flags.DontSave | CCObject.Flags.HideInHierarchy;
cameraNode.hideFlags |= CCObjectFlags.DontSave | CCObjectFlags.HideInHierarchy;
this.node.scene.addChild(cameraNode);

this._probe.initialize(this.node, cameraNode);
Expand Down
2 changes: 1 addition & 1 deletion cocos/core/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { legacyCC } from '../global-exports';
legacyCC._decorator = _decorator;
export { _decorator };
export { CCClass, isCCClassOrFastDefined } from './class';
export { CCObject } from './object';
export { CCObject, CCObjectFlags } from './object';
export { CCInteger, CCFloat, CCBoolean, CCString } from './utils/attribute';
export { CompactValueTypeArray } from './utils/compact-value-type-array';
export { editorExtrasTag } from './editor-extras-tag';
Expand Down
143 changes: 64 additions & 79 deletions cocos/core/data/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,45 @@
import { EditorExtendableObject, editorExtrasTag } from './editor-extras-tag';
import { copyAllProperties } from '../utils/js';

// definitions for CCObject.Flags

const Destroyed = 1 << 0;
const RealDestroyed = 1 << 1;
const ToDestroy = 1 << 2;
const DontSave = 1 << 3;
const EditorOnly = 1 << 4;
const Dirty = 1 << 5;
const DontDestroy = 1 << 6;
const Destroying = 1 << 7;
const Deactivating = 1 << 8;
const LockedInEditor = 1 << 9;
const HideInHierarchy = 1 << 10;

const IsOnEnableCalled = 1 << 11;
const IsEditorOnEnableCalled = 1 << 12;
const IsPreloadStarted = 1 << 13;
const IsOnLoadCalled = 1 << 14;
const IsOnLoadStarted = 1 << 15;
const IsStartCalled = 1 << 16;

const IsRotationLocked = 1 << 17;
const IsScaleLocked = 1 << 18;
const IsAnchorLocked = 1 << 19;
const IsSizeLocked = 1 << 20;
const IsPositionLocked = 1 << 21;

// var Hide = HideInGame | HideInEditor;
// should not clone or serialize these flags
const PersistentMask = ~(ToDestroy | Dirty | Destroying | DontDestroy | Deactivating
| IsPreloadStarted | IsOnLoadStarted | IsOnLoadCalled | IsStartCalled
| IsOnEnableCalled | IsEditorOnEnableCalled
| IsRotationLocked | IsScaleLocked | IsAnchorLocked | IsSizeLocked | IsPositionLocked
/* RegisteredInEditor */);

// all the hideFlags
const AllHideMasks = DontSave | EditorOnly | LockedInEditor | HideInHierarchy;
// definitions for CCObjectFlags

export enum CCObjectFlags {
Destroyed = 1 << 0,
RealDestroyed = 1 << 1,
ToDestroy = 1 << 2,
DontSave = 1 << 3,
EditorOnly = 1 << 4,
Dirty = 1 << 5,
DontDestroy = 1 << 6,
Destroying = 1 << 7,
Deactivating = 1 << 8,
LockedInEditor = 1 << 9,
HideInHierarchy = 1 << 10,

IsOnEnableCalled = 1 << 11,
IsEditorOnEnableCalled = 1 << 12,
IsPreloadStarted = 1 << 13,
IsOnLoadCalled = 1 << 14,
IsOnLoadStarted = 1 << 15,
IsStartCalled = 1 << 16,

IsRotationLocked = 1 << 17,
IsScaleLocked = 1 << 18,
IsAnchorLocked = 1 << 19,
IsSizeLocked = 1 << 20,
IsPositionLocked = 1 << 21,

// var Hide = HideInGame | HideInEditor,
// should not clone or serialize these flags
PersistentMask = ~(ToDestroy | Dirty | Destroying | DontDestroy | Deactivating
| IsPreloadStarted | IsOnLoadStarted | IsOnLoadCalled | IsStartCalled
| IsOnEnableCalled | IsEditorOnEnableCalled
| IsRotationLocked | IsScaleLocked | IsAnchorLocked | IsSizeLocked | IsPositionLocked
/* RegisteredInEditor */),

// all the hideFlags
AllHideMasks = DontSave | EditorOnly | LockedInEditor | HideInHierarchy,
}

const objectsToDestroy: CCObject[] = [];
let deferredDestroyTimer: number | null = null;
Expand Down Expand Up @@ -170,7 +172,7 @@
const deleteCount = objectsToDestroy.length;
for (let i = 0; i < deleteCount; ++i) {
const obj = objectsToDestroy[i];
if (!(obj._objFlags & Destroyed)) {
if (!(obj._objFlags & CCObjectFlags.Destroyed)) {
obj._destroyImmediate();
}
}
Expand Down Expand Up @@ -234,11 +236,11 @@
* @zh 在继承 CCObject 对象后,控制是否需要隐藏,锁定,序列化等功能。
*/
public set hideFlags (hideFlags: CCObject.Flags) {
const flags = hideFlags & CCObject.Flags.AllHideMasks;
this._objFlags = (this._objFlags & ~CCObject.Flags.AllHideMasks) | flags;
const flags = hideFlags & CCObjectFlags.AllHideMasks;
this._objFlags = (this._objFlags & ~CCObjectFlags.AllHideMasks) | flags;
}
public get hideFlags (): CCObject.Flags {
return this._objFlags & CCObject.Flags.AllHideMasks;
return this._objFlags & CCObjectFlags.AllHideMasks;
}

/**
Expand Down Expand Up @@ -268,7 +270,7 @@
* ```
*/
get isValid (): boolean {
return !(this._objFlags & Destroyed);
return !(this._objFlags & CCObjectFlags.Destroyed);
}

/**
Expand All @@ -288,14 +290,14 @@
* ```
*/
public destroy (): boolean {
if (this._objFlags & Destroyed) {
if (this._objFlags & CCObjectFlags.Destroyed) {
warnID(5000);
return false;
}
if (this._objFlags & ToDestroy) {
if (this._objFlags & CCObjectFlags.ToDestroy) {
return false;
}
this._objFlags |= ToDestroy;
this._objFlags |= CCObjectFlags.ToDestroy;
objectsToDestroy.push(this);

if (EDITOR_NOT_IN_PREVIEW && deferredDestroyTimer === null && legacyCC.engine && !legacyCC.engine._isUpdating) {
Expand Down Expand Up @@ -358,7 +360,7 @@
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
public _destroyImmediate (): void {
if (this._objFlags & Destroyed) {
if (this._objFlags & CCObjectFlags.Destroyed) {
errorID(5000);
return;
}
Expand All @@ -378,14 +380,14 @@
this._destruct();
}

this._objFlags |= Destroyed;
this._objFlags |= CCObjectFlags.Destroyed;
}
}

const prototype = CCObject.prototype;
if (EDITOR || TEST) {
js.get(prototype, 'isRealValid', function (this: CCObject) {

Check warning on line 389 in cocos/core/data/object.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
return !(this._objFlags & RealDestroyed);
return !(this._objFlags & CCObjectFlags.RealDestroyed);
});

/**
Expand All @@ -396,10 +398,10 @@
js.getset(
prototype,
'objFlags',
function (this: CCObject) {

Check warning on line 401 in cocos/core/data/object.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
return this._objFlags;
},
function (this: CCObject, objFlags: CCObject.Flags) {
function (this: CCObject, objFlags: CCObjectFlags) {

Check warning on line 404 in cocos/core/data/object.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
this._objFlags = objFlags;
},
);
Expand All @@ -416,17 +418,17 @@
* TODO: this is a dynamic inject method, should be define in class
* issue: https://github.com/cocos/cocos-engine/issues/14643
*/
(prototype as any).realDestroyInEditor = function (): void {

Check warning on line 421 in cocos/core/data/object.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
if (!(this._objFlags & Destroyed)) {
if (!(this._objFlags & CCObjectFlags.Destroyed)) {
warnID(5001);
return;
}
if (this._objFlags & RealDestroyed) {
if (this._objFlags & CCObjectFlags.RealDestroyed) {
warnID(5000);
return;
}
this._destruct();
this._objFlags |= RealDestroyed;
this._objFlags |= CCObjectFlags.RealDestroyed;
};
}

Expand Down Expand Up @@ -468,35 +470,18 @@
CCClass.fastDefine('cc.Object', CCObject, { _name: '', _objFlags: 0 });
}

const CCObjectFlagsEnum = {};
for (const key in CCObjectFlags) {
if (typeof key === 'string' && typeof CCObjectFlags[key] === 'number') {
CCObjectFlagsEnum[key] = CCObjectFlags[key];
}
}
/**
* Bit mask that controls object states.
* @enum Object.Flags
* @private
*/
js.value(CCObject, 'Flags', {
Destroyed,
DontSave,
EditorOnly,
Dirty,
DontDestroy,
PersistentMask,
Destroying,
Deactivating,
LockedInEditor,
HideInHierarchy,
AllHideMasks,
IsPreloadStarted,
IsOnLoadStarted,
IsOnLoadCalled,
IsOnEnableCalled,
IsStartCalled,
IsEditorOnEnableCalled,
IsPositionLocked,
IsRotationLocked,
IsScaleLocked,
IsAnchorLocked,
IsSizeLocked,
});
js.value(CCObject, 'Flags', CCObjectFlagsEnum);

declare namespace CCObject {
export enum Flags {
Expand Down Expand Up @@ -657,17 +642,17 @@
*/
export function isValid (value: any, strictMode?: boolean): boolean {
if (typeof value === 'object') {
return !!value && !(value._objFlags & (strictMode ? (Destroyed | ToDestroy) : Destroyed));
return !!value && !(value._objFlags & (strictMode ? (CCObjectFlags.Destroyed | CCObjectFlags.ToDestroy) : CCObjectFlags.Destroyed));
} else {
return typeof value !== 'undefined';
}
}
legacyCC.isValid = isValid;

if (EDITOR || TEST) {
js.value(CCObject, '_willDestroy', (obj) => !(obj._objFlags & Destroyed) && (obj._objFlags & ToDestroy) > 0);
js.value(CCObject, '_willDestroy', (obj) => !(obj._objFlags & CCObjectFlags.Destroyed) && (obj._objFlags & CCObjectFlags.ToDestroy) > 0);
js.value(CCObject, '_cancelDestroy', (obj) => {
obj._objFlags &= ~ToDestroy;
obj._objFlags &= ~CCObjectFlags.ToDestroy;
js.array.fastRemove(objectsToDestroy, obj);
});
}
Expand Down
7 changes: 3 additions & 4 deletions cocos/dragon-bones/ArmatureDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants';
import { Armature, Bone, EventObject, AnimationState } from '@cocos/dragonbones-js';
import { UIRenderer } from '../2d/framework/ui-renderer';
import { Color, Enum, ccenum, errorID, RecyclePool, js, CCObject, EventTarget, cclegacy, _decorator, warn } from '../core';
import { Color, Enum, ccenum, errorID, RecyclePool, js, EventTarget, cclegacy, _decorator, warn, CCObjectFlags } from '../core';
import { BlendFactor } from '../gfx';
import { AnimationCache, ArmatureCache, ArmatureFrame } from './ArmatureCache';
import { AttachUtil } from './AttachUtil';
Expand Down Expand Up @@ -336,7 +336,7 @@

const animName = animsEnum[this._animationIndex];
if (animName !== undefined) {
this.playAnimation(animName, this.playTimes);

Check failure on line 339 in cocos/dragon-bones/ArmatureDisplay.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`
} else {
errorID(7402, this.name);
}
Expand Down Expand Up @@ -613,8 +613,8 @@
this._inited = false;
this.attachUtil = new AttachUtil();
this.initFactory();
setPropertyEnumType(this, '_animationIndex', this._enumAnimations);

Check failure on line 616 in cocos/dragon-bones/ArmatureDisplay.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `EnumType`
setPropertyEnumType(this, '_defaultArmatureIndex', this._enumArmatures);

Check failure on line 617 in cocos/dragon-bones/ArmatureDisplay.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `EnumType`
this._useVertexOpacity = true;
}
/**
Expand Down Expand Up @@ -759,8 +759,7 @@
*/
_init (): void {
if (EDITOR_NOT_IN_PREVIEW) {
const Flags = CCObject.Flags;
this._objFlags |= (Flags.IsAnchorLocked | Flags.IsSizeLocked);
this._objFlags |= (CCObjectFlags.IsAnchorLocked | CCObjectFlags.IsSizeLocked);
// this._refreshInspector();
}

Expand Down Expand Up @@ -998,7 +997,7 @@
if (this.debugBones) {
if (!this._debugDraw) {
const debugDrawNode = new Node('DEBUG_DRAW_NODE');
debugDrawNode.hideFlags |= CCObject.Flags.DontSave | CCObject.Flags.HideInHierarchy;
debugDrawNode.hideFlags |= CCObjectFlags.DontSave | CCObjectFlags.HideInHierarchy;
const debugDraw = debugDrawNode.addComponent(Graphics);
debugDraw.lineWidth = 1;
debugDraw.strokeColor = new Color(255, 0, 0, 255);
Expand Down Expand Up @@ -1160,7 +1159,7 @@
} else {
Object.assign(this._cacheModeEnum, DefaultCacheMode);
}
setPropertyEnumType(this, '_defaultCacheMode', this._cacheModeEnum);

Check failure on line 1162 in cocos/dragon-bones/ArmatureDisplay.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `EnumType`
}

// update animation list for editor
Expand All @@ -1179,7 +1178,7 @@
Object.assign(this._enumAnimations, animEnum || DefaultAnimsEnum);
Enum.update(this._enumAnimations);
// change enum
setPropertyEnumType(this, '_animationIndex', this._enumAnimations);

Check failure on line 1181 in cocos/dragon-bones/ArmatureDisplay.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `EnumType`
}

// update armature list for editor
Expand All @@ -1198,7 +1197,7 @@
Object.assign(this._enumArmatures, armatureEnum || DefaultArmaturesEnum);
Enum.update(this._enumArmatures);
// change enum
setPropertyEnumType(this, '_defaultArmatureIndex', this._enumArmatures);

Check failure on line 1200 in cocos/dragon-bones/ArmatureDisplay.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `EnumType`
}
/**
* @engineInternal Since v3.7.2 this is an engine private function.
Expand All @@ -1217,7 +1216,7 @@
(bone as any).path = bone.name;
return bone.name;
}
const name = `${cacheBoneName((bone.parent as any)._boneIndex, bones, cache)}/${bone.name}`;

Check failure on line 1219 in cocos/dragon-bones/ArmatureDisplay.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `BoneIndex`
cache.set(bi, name);
(bone as any).path = name;
return name;
Expand Down Expand Up @@ -1420,7 +1419,7 @@
* @zh 调用回调函数的对象,可以为 null。
*/
addEventListener (eventType, listener, target): void {
this._eventTarget.on(eventType, listener, target);

Check failure on line 1422 in cocos/dragon-bones/ArmatureDisplay.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `EventType`
}

/**
Expand All @@ -1435,7 +1434,7 @@
* @zh 调用回调函数的对象,可以为 null。
*/
removeEventListener (eventType, listener, target): void {
this._eventTarget.off(eventType, listener, target);

Check failure on line 1437 in cocos/dragon-bones/ArmatureDisplay.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `EventType`
}

/**
Expand Down Expand Up @@ -1488,7 +1487,7 @@
if (socket.path && socket.target) {
const bone = this._cachedSockets.get(socket.path);
if (!bone) {
console.error(`Skeleton data does not contain path ${socket.path}`);

Check failure on line 1490 in cocos/dragon-bones/ArmatureDisplay.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected console statement
continue;
}
socket.boneIndex = bone as unknown as number;
Expand Down
8 changes: 4 additions & 4 deletions cocos/game/director.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import { DEBUG, EDITOR, BUILD, TEST, EDITOR_NOT_IN_PREVIEW } from 'internal:constants';
import { SceneAsset } from '../asset/assets/scene-asset';
import { System, EventTarget, Scheduler, js, errorID, error, assertID, warnID, macro, CCObject, cclegacy, isValid } from '../core';
import { System, EventTarget, Scheduler, js, errorID, error, assertID, warnID, macro, CCObject, CCObjectFlags, cclegacy, isValid } from '../core';
import { input } from '../input';
import { Root } from '../root';
import { Node, NodeEventType, Scene } from '../scene-graph';
Expand Down Expand Up @@ -422,12 +422,12 @@ export class Director extends EventTarget {
// scene also contains the persist node, select the old one
const index = existNode.siblingIndex;
// restore to the old saving flag
node.hideFlags &= ~CCObject.Flags.DontSave;
node.hideFlags |= CCObject.Flags.DontSave & existNode.hideFlags;
node.hideFlags &= ~CCObjectFlags.DontSave;
node.hideFlags |= CCObjectFlags.DontSave & existNode.hideFlags;
existNode._destroyImmediate();
scene.insertChild(node, index);
} else {
node.hideFlags |= CCObject.Flags.DontSave;
node.hideFlags |= CCObjectFlags.DontSave;
node.parent = scene;
}
}
Expand Down
Loading
Loading