diff --git a/cocos/particle/animator/curve-range.ts b/cocos/particle/animator/curve-range.ts index bfcda53496..8d4bba3aa4 100644 --- a/cocos/particle/animator/curve-range.ts +++ b/cocos/particle/animator/curve-range.ts @@ -23,7 +23,7 @@ */ import { ccclass } from 'cc.decorator'; -import { EDITOR } from 'internal:constants'; +import { EDITOR, NODEJS } from 'internal:constants'; import { lerp, RealCurve, CCClass, geometry, Enum, approx, EPSILON } from '../../core'; import { PixelFormat, TextureFilter, WrapMode } from '../../asset/assets/asset-enum'; import { Texture2D, ImageAsset } from '../../asset/assets'; @@ -197,7 +197,7 @@ export default class CurveRange { constructor () { /* Only create RealCurves in Editor, in order to show the Splines in Editor, in RunTime the RealCurves will only be created when it is in Curve mode*/ - if (EDITOR) { + if (EDITOR || NODEJS) { this.spline = geometry.constructLegacyCurveAndConvert(); this.splineMin = geometry.constructLegacyCurveAndConvert(); this.splineMax = geometry.constructLegacyCurveAndConvert(); diff --git a/cocos/scene-graph/component-scheduler.ts b/cocos/scene-graph/component-scheduler.ts index 654086409b..8a3f659817 100644 --- a/cocos/scene-graph/component-scheduler.ts +++ b/cocos/scene-graph/component-scheduler.ts @@ -22,7 +22,7 @@ THE SOFTWARE. */ -import { EDITOR, SUPPORT_JIT, DEV, TEST } from 'internal:constants'; +import { EDITOR, SUPPORT_JIT, DEV, TEST, NODEJS } from 'internal:constants'; import { CCObjectFlags } from '../core/data/object'; import { js } from '../core'; import { tryCatchFunctor_EDITOR } from '../core/utils/misc'; @@ -36,9 +36,9 @@ const IsStartCalled = CCObjectFlags.IsStartCalled; const IsOnEnableCalled = CCObjectFlags.IsOnEnableCalled; const IsEditorOnEnableCalled = CCObjectFlags.IsEditorOnEnableCalled; -const callerFunctor: any = EDITOR && tryCatchFunctor_EDITOR; -const callOnEnableInTryCatch: any = EDITOR && callerFunctor('onEnable'); -const callOnDisableInTryCatch: any = EDITOR && callerFunctor('onDisable'); +const callerFunctor: any = (EDITOR || NODEJS) && tryCatchFunctor_EDITOR; +const callOnEnableInTryCatch: any = (EDITOR || NODEJS) && callerFunctor('onEnable'); +const callOnDisableInTryCatch: any = (EDITOR || NODEJS) && callerFunctor('onDisable'); function sortedIndex (array, comp): number { const order = comp.constructor._executionOrder; @@ -550,7 +550,7 @@ export class ComponentScheduler { } } -if (EDITOR) { +if (EDITOR || NODEJS) { ComponentScheduler.prototype.enableComp = function (comp, invoker): void { // NOTE: _executeInEditMode is dynamically injected on Editor environment if (legacyCC.GAME_VIEW || (comp.constructor as any)._executeInEditMode) { diff --git a/cocos/scene-graph/node-activator.ts b/cocos/scene-graph/node-activator.ts index 294a41805a..4d4abeab91 100644 --- a/cocos/scene-graph/node-activator.ts +++ b/cocos/scene-graph/node-activator.ts @@ -22,7 +22,7 @@ THE SOFTWARE. */ -import { EDITOR, DEV, SUPPORT_JIT, DEBUG } from 'internal:constants'; +import { EDITOR, DEV, SUPPORT_JIT, DEBUG, NODEJS } from 'internal:constants'; import { CCObjectFlags, isValid } from '../core/data/object'; import { array, Pool } from '../core/utils/js'; import { tryCatchFunctor_EDITOR } from '../core/utils/misc'; @@ -327,7 +327,7 @@ export default class NodeActivator { } } -if (EDITOR) { +if (EDITOR || NODEJS) { const callPreloadInTryCatch = tryCatchFunctor_EDITOR('__preload'); const callOnLoadInTryCatch = function (c: Component): void { try { @@ -344,7 +344,7 @@ if (EDITOR) { const _onLoadInEditor = (comp: Component): void => { if (comp.internalOnLoad && !legacyCC.GAME_VIEW) { - const focused = Editor.Selection.getLastSelected('node') === comp.node.uuid; + const focused = !NODEJS && Editor.Selection.getLastSelected('node') === comp.node.uuid; if (focused) { if (comp.onFocusInEditor && callOnFocusInTryCatch) { callOnFocusInTryCatch(comp); diff --git a/cocos/video/video-player.ts b/cocos/video/video-player.ts index 38a07b44d6..2c3bbb11cb 100644 --- a/cocos/video/video-player.ts +++ b/cocos/video/video-player.ts @@ -23,7 +23,7 @@ */ import { ccclass, displayOrder, executeInEditMode, help, menu, slide, range, requireComponent, tooltip, type, serializable } from 'cc.decorator'; -import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants'; +import { EDITOR_NOT_IN_PREVIEW, NODEJS } from 'internal:constants'; import { warn } from '../core/platform'; import { Component, EventHandler as ComponentEventHandler } from '../scene-graph'; import { UITransform } from '../2d/framework'; @@ -393,7 +393,7 @@ export class VideoPlayer extends Component { } public __preload (): void { - if (EDITOR_NOT_IN_PREVIEW) { + if (EDITOR_NOT_IN_PREVIEW || NODEJS) { return; } this._impl = VideoPlayerImplManager.getImpl(this);