Skip to content

Constructor

This extended node inherits from EventEmitter.

EntityNode()

Instantiates an extended node class.

Components can only be attached to extended nodes.

Input Parameters

ParameterRequiredDefaultTypeDescription
entityYesTA game entity, which can be any entity such as a character, item, UI element, etc.

Return Value

TypeDescription
EntityNodeThe extended node class

Static Properties

isMonitoringEnabled

Sets whether to enable global performance monitoring. Defaults to true.

When enabled, the Component.update method of all components will be tracked by the performance monitor to record and analyze their execution performance. Disabling this option can reduce performance overhead and is suitable for production environments or scenarios where performance monitoring is not required.

Properties

uuid

Gets the UUID of this node.


components

Gets all component instances on this node.


entity

Gets the associated game entity.


enable

The enabled state of the node, which affects the per-frame update and the enabled state of components on the node.

Static Methods

onPerformanceWarning()

Sets the global performance warning callback for components.

Input Parameters

ParameterRequiredDefaultTypeDescription
eventYes(event: IonPerformanceData) => voidThe callback method

Methods

addComponent()

Adds a component of the specified type to this node.

[Using component constructor]

Input Parameters

ParameterRequiredDefaultTypeDescription
componentConstructorYesnew (...args: any[]) => UThe component constructor
objectNo{}Partial‹Omit‹U, keyof Component‹T›››Initial properties for the component, does not modify properties by default

addComponent()

Adds a component of the specified type to this node.

The child component class must have the @apclass decorator. Otherwise, the component instance cannot be obtained.

[Using component name]

Input Parameters

ParameterRequiredDefaultTypeDescription
componentNameYesstringThe component name
objectNo{}Record<string, any>Initial properties for the component, does not modify properties by default

getComponent()

Gets a component of the specified type on this node.

[Using component name]

Input Parameters

ParameterRequiredDefaultTypeDescription
componentNameYesstringThe component name

getComponent()

Gets a component of the specified type on this node.

[Using component constructor]

Input Parameters

ParameterRequiredDefaultTypeDescription
componentConstructorYesnew (...args: any[]) => UThe component constructor

getComponentPerformance()

Gets the performance data for a specified component on this node.

[Using component name]

Input Parameters

ParameterRequiredDefaultTypeDescription
componentNameYesstringThe component name

getComponentPerformance()

Gets the performance data for a specified component on this node.

[Using component constructor]

Input Parameters

ParameterRequiredDefaultTypeDescription
componentConstructorYesnew (...args: any[]) => UThe component constructor

getComponents()

Gets all components on this node.


removeComponent()

Removes a component of the specified type from the node.

[Using component name]

Input Parameters

ParameterRequiredDefaultTypeDescription
componentNameYesstringThe component name

removeComponent()

Removes a component of the specified type from the node.

[Using component constructor]

Input Parameters

ParameterRequiredDefaultTypeDescription
componentConstructorYesnew (...args: any[]) => UThe component constructor

removeComponentAll()

Removes all components from the node.


destroy()

Removes the node and all its components, and cleans up related resources.

Functions

find()

Gets a registered node instance from the global registry by entity or UUID.

  • Priority: entity > uuid

Input Parameters

ParameterRequiredDefaultTypeDescription
entityOrUUIDYesUThe game entity or node UUID

神岛实验室