mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
[feat] add _registerIfAttached for NODEJS platform (#25)
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { EDITOR, DEV, TEST } from 'internal:constants';
|
||||
import { EDITOR, DEV, TEST, NODEJS } from 'internal:constants';
|
||||
import { CCObjectFlags } from '../core/data/object';
|
||||
import * as js from '../core/utils/js';
|
||||
import { legacyCC } from '../core/global-exports';
|
||||
@@ -45,7 +45,7 @@ export function nodePolyfill (Node): void {
|
||||
};
|
||||
}
|
||||
|
||||
if (EDITOR || TEST) {
|
||||
if (EDITOR || TEST || NODEJS) {
|
||||
Node.prototype._checkMultipleComp = function (ctor): boolean {
|
||||
const existing = this.getComponent(ctor._disallowMultiple);
|
||||
if (existing) {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
import { ccclass, editable, serializable, type } from 'cc.decorator';
|
||||
import { DEV, DEBUG, EDITOR, EDITOR_NOT_IN_PREVIEW, USE_UI_SKEW } from 'internal:constants';
|
||||
import { DEV, DEBUG, EDITOR, EDITOR_NOT_IN_PREVIEW, USE_UI_SKEW, NODEJS } from 'internal:constants';
|
||||
import { Layers } from './layers';
|
||||
import { NodeUIProperties } from './node-ui-properties';
|
||||
import { cclegacy } from '../core/global-exports';
|
||||
@@ -1497,7 +1497,7 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable {
|
||||
// detach self and children from editor
|
||||
const parent = this._parent;
|
||||
const destroyByParent: boolean = (!!parent) && ((parent._objFlags & Destroying) !== 0);
|
||||
if (!destroyByParent && EDITOR) {
|
||||
if (!destroyByParent && (EDITOR || NODEJS)) {
|
||||
// TODO: `_registerIfAttached` is injected property
|
||||
// issue: https://github.com/cocos/cocos-engine/issues/14643
|
||||
(this as any)._registerIfAttached!(false);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
import { ccclass, serializable, editable } from 'cc.decorator';
|
||||
import { EDITOR, TEST } from 'internal:constants';
|
||||
import { EDITOR, NODEJS, TEST } from 'internal:constants';
|
||||
import { CCObject } from '../core/data/object';
|
||||
import { assert, getError } from '../core/platform/debug';
|
||||
import { RenderScene } from '../render-scene/core/render-scene';
|
||||
@@ -192,7 +192,7 @@ export class Scene extends Node {
|
||||
* @mangle
|
||||
*/
|
||||
public _activate (active = true): void {
|
||||
if (EDITOR) {
|
||||
if (EDITOR || NODEJS) {
|
||||
// register all nodes to editor
|
||||
// TODO: `_registerIfAttached` is injected property
|
||||
// issue: https://github.com/cocos/cocos-engine/issues/14643
|
||||
|
||||
Reference in New Issue
Block a user