Class: SkeletalAnimation
extend:
Animation
Import example:
import { SkeletalAnimation } from "cc";
Skeletal animation component, offers the following features on top of Animation:
- Choice between baked animation and real-time calculation, to leverage efficiency and expressiveness.
- Joint socket system: Create any socket node directly under the animation component root node, find your target joint and register both to the socket list, so that the socket node would be in-sync with the joint.
Index
Constructors
-
SkeletalAnimation
public
Static Properties
-
Socket
static
Properties
-
useBakedAnimation
public
Whether to bake animations. Default to true,
which substantially increases performance while making all animations completely fixed.
Dynamically changing this property will take effect when playing the next animation clip.Note, in editor(not in preview) mode, this option takes no effect: animation is always non-baked.
which substantially increases performance while making all animations completely fixed.
Dynamically changing this property will take effect when playing the next animation clip.Note, in editor(not in preview) mode, this option takes no effect: animation is always non-baked.
-
sockets
public
The joint sockets this animation component maintains.
Sockets have to be registered here before attaching custom nodes to animated joints.
Sockets have to be registered here before attaching custom nodes to animated joints.
-
_currentBakedState
protected
-
_sockets
protected
-
_useBakedAnimation
protected
-
_users
protected
-
_useBakedEffectively
protected
Methods
-
rebuildSocketAnimations
public
Rebuild animations to synchronize immediately all sockets to their target node.
-
querySockets
public
Query all socket paths
-
notifySkinnedMeshRemoved
public
-
notifySkinnedMeshAdded
public
-
getUsers
public
-
createSocket
public
Create or get the target node from a socket.If a socket haven't been created for the corresponding path, this function will register a new socket.
-
_applyBakeFlagChange
protected
-
_removeAllUsers
protected
Inherited Properties
-
uuid
public
The uuid for editor.
-
name
public
-
isValid
public
Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
When an object's destroy is called, it is actually destroyed after the end of this frame.So isValid will return false from the next frame, while isValid in the current frame will still be true.If you want to determine whether the current frame has called destroy, use isValid(obj, true),but this is often caused by a particular logical requirements, which is not normally required.
When an object's destroy is called, it is actually destroyed after the end of this frame.So isValid will return false from the next frame, while isValid in the current frame will still be true.If you want to determine whether the current frame has called destroy, use isValid(obj, true),but this is often caused by a particular logical requirements, which is not normally required.
-
hideFlags
public
After inheriting CCObject objects, control whether you need to hide, lock, serialize, and other functions.
-
enabledInHierarchy
public
Indicates whether this component is enabled and its node is also active in the hierarchy.
-
enabled
public
Indicates whether this component is enabled or not.
-
defaultClip
public
Gets or sets the default clip.Two clips that both have same non-empty UUID are treat as equivalent.
-
clips
public
Gets or sets clips this component governs.When set, associated animation state of each existing clip will be stopped.If the existing default clip is not in the set of new clips, default clip will be reset to null.
-
playOnLoad
public
Whether the default clip should get into playing when this components starts.Note, this field takes no effect if crossFade() or play() has been called before this component starts.
-
node
public
The node this component is attached to. A component is always attached to a node.
-
__editorExtras__
protected
-
__prefab
protected
-
_clips
protected
-
_crossFade
protected
-
_defaultClip
protected
-
_enabled
protected
-
_id
protected
-
_name
protected
-
_nameToState
protected
-
_objFlags
protected
-
_sceneGetter
protected
-
__scriptAsset
protected
-
_isOnLoadCalled
protected
Returns a value which used to indicate the onLoad get called or not.
Inherited Methods
-
unscheduleAllCallbacks
public
unschedule all scheduled tasks.
-
unschedule
public
Un-schedules a custom task.
-
targetOff
public
Removes all callbacks previously registered with the same target (passed as parameter).This is not for removing all listeners in the current event target,and this is not for removing all listeners the target parameter have registered.It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
-
stop
public
-
start
public
-
scheduleOnce
public
Use Scheduler system to schedule a task that runs only once, with a delay of 0 or larger.
-
schedule
public
Use Scheduler system to schedule a custom task.
If the task is already scheduled, then the interval parameter will be updated without scheduling it again.
If the task is already scheduled, then the interval parameter will be updated without scheduling it again.
-
resume
public
-
resetInEditor
public
Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used.This function is only called in editor.
-
removeState
public
Stops and removes specified clip.
-
removeClip
public
Remove clip from the animation list. This will remove the clip and any animation states based on it.
If there are animation states depend on the clip are playing or clip is defaultClip, it will not delete the clip.
But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip,defaultClip will be reset to null
If there are animation states depend on the clip are playing or clip is defaultClip, it will not delete the clip.
But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip,defaultClip will be reset to null
-
removeAll
public
Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
-
play
public
Switch to play specified animation state, without fading.
-
pause
public
-
once
public
-
onLostFocusInEditor
public
-
onLoad
public
-
onFocusInEditor
public
-
onEnable
public
-
onDisable
public
-
onDestroy
public
-
on
public
Register animation event callback.The event arguments will provide the AnimationState which emit the event.When play an animation, will auto register the event callback to the AnimationState,and unregister the event callback from the AnimationState when animation stopped.
-
off
public
Unregister animation event callback.
-
hasEventListener
public
Checks whether there is correspond event listener registered on the given event.
-
getState
public
Get specified animation state.
-
getComponentsInChildren
public
Returns all components of supplied type in self or any of its children.
-
getComponents
public
Returns all components of supplied type in the node.
-
getComponentInChildren
public
Returns the component of supplied type in any of its children using depth first search.
-
getComponent
public
Returns the component of supplied type if the node has one attached, null if it doesn't.
You can also get component in the node by passing in the name of the script.
You can also get component in the node by passing in the name of the script.
-
emit
public
Trigger an event directly with the event name and necessary arguments.
-
destroy
public
-
crossFade
public
Smoothly switch to play specified animation state.
-
createState
public
Creates a state for specified clip.If there is already a clip with same name, the existing animation state will be stopped and overridden.
-
addComponent
public
Adds a component class to the node. You can also add component to node by passing in the name of the script.
-
addClip
public
Adds an animation clip into this component and creates a animation state for this clip.
-
__preload
protected
__preload is called before every onLoad.
It is used to initialize the builtin components internally,
to avoid checking whether onLoad is called before every public method calls.
This method should be removed if script priority is supported.
It is used to initialize the builtin components internally,
to avoid checking whether onLoad is called before every public method calls.
This method should be removed if script priority is supported.
-
_createState
protected
-
_destroyImmediate
protected
-
_destruct
protected
Clear all references in the instance.NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject.
-
_doCreateState
protected
-
_getLocalBounds
protected
If the component's bounding box is different from the node's, you can implement this method to supplya custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly.
-
_getRenderScene
protected
-
_instantiate
protected
-
_onPreDestroy
protected
-
doPlayOrCrossFade
protected
-
lateUpdate
protected
LateUpdate is called every frame, if the Component is enabled.
This is a lifecycle method. It may not be implemented in the super class.
You can only call its super class method inside it. It should not be called manually elsewhere.
This is a lifecycle method. It may not be implemented in the super class.
You can only call its super class method inside it. It should not be called manually elsewhere.
-
onRestore
protected
onRestore is called after the user clicks the Reset item in the Inspector's context menu or performsan undo operation on this component.
If the component contains the "internal state", short for "temporary member variables which not included
in its CCClass properties", then you may need to implement this function.
The editor will call the getset accessors of your component to record/restore the component's state
for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
this function to manually synchronize your component's "internal states" with its public properties.
Once you implement this function, all the getset accessors of your component will not be called when
the user performs an undo/redo operation. Which means that only the properties with default value
will be recorded or restored by editor.
Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
to support the reset menu, you should manually synchronize your component's "internal states" with its
properties in this function. Once you implement this function, all the getset accessors of your component
will not be called during reset operation. Which means that only the properties with default value
will be reset by editor.This function is only called in editor mode.
If the component contains the "internal state", short for "temporary member variables which not included
in its CCClass properties", then you may need to implement this function.
The editor will call the getset accessors of your component to record/restore the component's state
for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
this function to manually synchronize your component's "internal states" with its public properties.
Once you implement this function, all the getset accessors of your component will not be called when
the user performs an undo/redo operation. Which means that only the properties with default value
will be recorded or restored by editor.
Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
to support the reset menu, you should manually synchronize your component's "internal states" with its
properties in this function. Once you implement this function, all the getset accessors of your component
will not be called during reset operation. Which means that only the properties with default value
will be reset by editor.This function is only called in editor mode.
-
update
protected
Update is called every frame, if the Component is enabled.
This is a lifecycle method. It may not be implemented in the super class.
You can only call its super class method inside it. It should not be called manually elsewhere.
This is a lifecycle method. It may not be implemented in the super class.
You can only call its super class method inside it. It should not be called manually elsewhere.
Details
Constructors
Inherited from: Animation.constructor
Static Properties
Properties
public useBakedAnimation : boolean
Whether to bake animations. Default to true,
which substantially increases performance while making all animations completely fixed.
Dynamically changing this property will take effect when playing the next animation clip. Note, in editor(not in preview) mode, this option takes no effect: animation is always non-baked.
which substantially increases performance while making all animations completely fixed.
Dynamically changing this property will take effect when playing the next animation clip. Note, in editor(not in preview) mode, this option takes no effect: animation is always non-baked.
The joint sockets this animation component maintains.
Sockets have to be registered here before attaching custom nodes to animated joints.
Sockets have to be registered here before attaching custom nodes to animated joints.
protected _useBakedEffectively : boolean
Methods
Get all users.
Returns: Set < SkinnedMeshRenderer >
Create or get the target node from a socket.
If a socket haven't been created for the corresponding path, this function will register a new socket.
Inherited Properties
The uuid for editor.
example
import { log } from 'cc';
log(comp.uuid);
Defined in
cocos/scene-graph/component.ts:105
Defined in
cocos/scene-graph/component.ts:75
Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
When an object's `destroy` is called, it is actually destroyed after the end of this frame. So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. If you want to determine whether the current frame has called `destroy`, use `isValid(obj, true)`, but this is often caused by a particular logical requirements, which is not normally required.
When an object's `destroy` is called, it is actually destroyed after the end of this frame. So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true. If you want to determine whether the current frame has called `destroy`, use `isValid(obj, true)`, but this is often caused by a particular logical requirements, which is not normally required.
example
import { Node, log } from 'cc';
const node = new Node();
log(node.isValid); // true
node.destroy();
log(node.isValid); // true, still valid in this frame
// after a frame...
log(node.isValid); // false, destroyed in the end of last frame
Defined in
cocos/core/data/object.ts:278
After inheriting CCObject objects, control whether you need to hide, lock, serialize, and other functions.
Defined in
cocos/core/data/object.ts:244
Indicates whether this component is enabled and its node is also active in the hierarchy.
example
import { log } from 'cc';
log(comp.enabledInHierarchy);
Defined in
cocos/scene-graph/component.ts:156
Indicates whether this component is enabled or not.
example
import { log } from 'cc';
comp.enabled = true;
log(comp.enabled);
Defined in
cocos/scene-graph/component.ts:129
Gets or sets the default clip.
Two clips that both have same non-empty UUID are treat as equivalent.
Defined in
cocos/animation/animation-component.ts:105
Gets or sets clips this component governs.
When set, associated animation state of each existing clip will be stopped.
If the existing default clip is not in the set of new clips, default clip will be reset to null.
Defined in
cocos/animation/animation-component.ts:63
Whether the default clip should get into playing when this components starts.
Note, this field takes no effect if `crossFade()` or `play()` has been called before this component starts.
Defined in
cocos/animation/animation-component.ts:133
The node this component is attached to. A component is always attached to a node.
example
import { log } from 'cc';
log(comp.node);
Defined in
cocos/scene-graph/component.ts:188
protected __editorExtras__ : unknown
Inherited from: __editorExtras__
Defined in
cocos/core/data/object.ts:195
Defined in
cocos/scene-graph/component.ts:200
Defined in
cocos/animation/animation-component.ts:149
Defined in
cocos/animation/animation-component.ts:138
Defined in
cocos/animation/animation-component.ts:155
protected _enabled : boolean
default: true
deprecated
Inherited from: _enabled
Deprecated: since v3.5.0, this is an engine private interface that will be removed in the future.
Defined in
cocos/scene-graph/component.ts:194
protected _id : string
deprecated
Inherited from: _id
Deprecated: since v3.5.0, this is an engine private interface that will be removed in the future.
Defined in
cocos/scene-graph/component.ts:211
Defined in
cocos/core/data/object.ts:207
Defined in
cocos/animation/animation-component.ts:143
Defined in
cocos/core/data/object.ts:200
Defined in
cocos/scene-graph/component.ts:205
protected __scriptAsset : null
deprecated
Inherited from: Animation.__scriptAsset
Deprecated: since v3.5.0, this is an engine private interface that will be removed in the future.
Defined in
cocos/scene-graph/component.ts:116
protected _isOnLoadCalled : number
deprecated
Inherited from: Animation._isOnLoadCalled
Deprecated: since v3.5.0, this is an engine private interface that will be removed in the future.
Returns a value which used to indicate the onLoad get called or not.
example
import { log } from 'cc';
log(this._isOnLoadCalled > 0);
Defined in
cocos/scene-graph/component.ts:172
Inherited Methods
public unscheduleAllCallbacks () : void
Inherited from: Animation.unscheduleAllCallbacks
unschedule all scheduled tasks.
Returns: void
example
this.unscheduleAllCallbacks();
Defined in
cocos/scene-graph/component.ts:512
Inherited from: Animation.unschedule
Un-schedules a custom task.
Input Parameters
Name | Type | Description |
---|---|---|
callback_fn | any | The callback function of the task |
Returns: void
example
this.unschedule(_callback);
Defined in
cocos/scene-graph/component.ts:496
Inherited from: Animation.targetOff
Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
Input Parameters
Name | Type | Description |
---|---|---|
typeOrTarget | any | The target to be searched for all related listeners |
Returns: void
Inherited from: Animation.scheduleOnce
Use Scheduler system to schedule a task that runs only once, with a delay of 0 or larger.
Defined in
cocos/scene-graph/component.ts:483
Inherited from: Animation.schedule
Use Scheduler system to schedule a custom task.
If the task is already scheduled, then the interval parameter will be updated without scheduling it again.
If the task is already scheduled, then the interval parameter will be updated without scheduling it again.
Input Parameters
Name | Type | Description |
---|---|---|
callback | any | The callback function of the task |
interval | number | The time interval between each invocation |
repeat | number | The repeat count of this task, the task will be invoked (repeat + 1) times, use [[24197]] to repeat a task forever |
delay | number | The delay time for the first invocation, Unit: s |
Returns: void
example
import { log } from 'cc';
this.schedule((dt) => void log(`time: ${dt}`), 1);
Defined in
cocos/scene-graph/component.ts:450
Inherited from: Animation.resetInEditor
Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used.
This function is only called in editor.
Defined in
cocos/scene-graph/component.ts:670
Inherited from: Animation.removeState
Stops and removes specified clip.
Defined in
cocos/animation/animation-component.ts:298
Inherited from: Animation.removeClip
Remove clip from the animation list. This will remove the clip and any animation states based on it.
If there are animation states depend on the clip are playing or clip is defaultClip, it will not delete the clip.
But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null
If there are animation states depend on the clip are playing or clip is defaultClip, it will not delete the clip.
But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null
Input Parameters
Name | Type | Description |
---|---|---|
clip | AnimationClip | - |
force | boolean | If force is true, then will always remove the clip and any animation states based on it. |
Returns: void
Defined in
cocos/animation/animation-component.ts:335
Inherited from: Animation.removeAll
Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
Input Parameters
Name | Type | Description |
---|---|---|
typeOrTarget | any | The event type or target with which the listeners will be removed |
Returns: void
Inherited from: Animation.play
Switch to play specified animation state, without fading.
Defined in
cocos/animation/animation-component.ts:200
public once <TFunction extends > (type : AnimationStateEventType, callback : TFunction, thisArg ?: any) : TFunction
Inherited from: TFunction
Input Parameters
Name | Type | Description |
---|---|---|
type | AnimationStateEventType | - |
callback | TFunction | - |
thisArg | any | - |
Returns: TFunction
Defined in
cocos/animation/animation-component.ts:399
Defined in
cocos/scene-graph/component.ts:663
Defined in
cocos/scene-graph/component.ts:661
public on <TFunction extends > (type : AnimationStateEventType, callback : TFunction, thisArg ?: any, once ?: boolean) : TFunction
Inherited from: TFunction
Register animation event callback.
The event arguments will provide the AnimationState which emit the event.
When play an animation, will auto register the event callback to the AnimationState,
and unregister the event callback from the AnimationState when animation stopped.
Input Parameters
Name | Type | Description |
---|---|---|
type | AnimationStateEventType | The event type to listen to |
callback | TFunction | The callback when event triggered |
thisArg | any | - |
once | boolean | - |
Returns: TFunction
example
onPlay: function (type, state) {
// callback
}
// register event to all animation
animation.on('play', this.onPlay, this);
Defined in
cocos/animation/animation-component.ts:391
Inherited from: Animation.off
Unregister animation event callback.
Defined in
cocos/animation/animation-component.ts:421
Defined in
cocos/animation/animation-component.ts:265
public getComponentsInChildren <T extends Component> (classConstructor : Constructor < Component > | AbstractedConstructor < Component >) : Component []
Inherited from: Animation.getComponentsInChildren
Returns all components of supplied type in self or any of its children.
Inherited from: Animation.getComponentsInChildren
Returns all components of supplied type in self or any of its children.
Defined in
cocos/scene-graph/component.ts:359
public getComponents <T extends Component> (classConstructor : Constructor < Component > | AbstractedConstructor < Component >) : Component []
Inherited from: Animation.getComponents
Returns all components of supplied type in the node.
Inherited from: Animation.getComponents
Returns all components of supplied type in the node.
Defined in
cocos/scene-graph/component.ts:303
public getComponentInChildren <T extends Component> (classConstructor : Constructor < Component > | AbstractedConstructor < Component >) : null | Component
Inherited from: Animation.getComponentInChildren
Returns the component of supplied type in any of its children using depth first search.
Inherited from: Animation.getComponentInChildren
Returns the component of supplied type in any of its children using depth first search.
Defined in
cocos/scene-graph/component.ts:331
public getComponent <T extends Component> (classConstructor : Constructor < Component > | AbstractedConstructor < Component >) : null | Component
Inherited from: Animation.getComponent
Returns the component of supplied type if the node has one attached, null if it doesn't.
You can also get component in the node by passing in the name of the script.
You can also get component in the node by passing in the name of the script.
Inherited from: Animation.getComponent
Returns the component of supplied type if the node has one attached, null if it doesn't.
You can also get component in the node by passing in the name of the script.
You can also get component in the node by passing in the name of the script.
Defined in
cocos/scene-graph/component.ts:270
public emit (type : EventType, arg0 ?: any, arg1 ?: any, arg2 ?: any, arg3 ?: any, arg4 ?: any) : void
Inherited from: Animation.emit
Trigger an event directly with the event name and necessary arguments.
Input Parameters
Name | Type | Description |
---|---|---|
type | EventType | event type |
arg0 | any | - |
arg1 | any | - |
arg2 | any | - |
arg3 | any | - |
arg4 | any | - |
Returns: void
Defined in
cocos/scene-graph/component.ts:379
Inherited from: Animation.crossFade
Smoothly switch to play specified animation state.
Defined in
cocos/animation/animation-component.ts:219
Inherited from: AnimationState
Creates a state for specified clip.
If there is already a clip with same name, the existing animation state will be stopped and overridden.
Input Parameters
Name | Type | Description |
---|---|---|
clip | AnimationClip | The animation clip |
name | string | The animation state name, if absent, the default clip's name will be used |
Returns: AnimationState
Defined in
cocos/animation/animation-component.ts:284
public addComponent <T extends Component> (classConstructor : Constructor < Component >) : null | Component
Inherited from: Animation.addComponent
Adds a component class to the node. You can also add component to node by passing in the name of the script.
Inherited from: Animation.addComponent
Adds a component class to the node. You can also add component to node by passing in the name of the script.
Defined in
cocos/scene-graph/component.ts:237
Inherited from: AnimationState
Adds an animation clip into this component and creates a animation state for this clip.
Input Parameters
Name | Type | Description |
---|---|---|
clip | AnimationClip | The animation clip |
name | string | The animation state name, if absent, the default clip's name will be used |
Returns: AnimationState
Defined in
cocos/animation/animation-component.ts:316
protected __preload () : void
Inherited from: Animation.__preload
`__preload` is called before every onLoad.
It is used to initialize the builtin components internally,
to avoid checking whether onLoad is called before every public method calls.
This method should be removed if script priority is supported.
It is used to initialize the builtin components internally,
to avoid checking whether onLoad is called before every public method calls.
This method should be removed if script priority is supported.
Returns: void
Defined in
cocos/scene-graph/component.ts:566
protected _destroyImmediate () : void
deprecated
Inherited from: Animation._destroyImmediate
Returns: void
Defined in
cocos/core/data/object.ts:368
protected _destruct () : void
deprecated
Inherited from: Animation._destruct
Deprecated: since v3.5.0, this is an engine private interface that will be removed in the future.
Clear all references in the instance.
NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject.
Returns: void
example
// You can override the _destruct method if you need, for example:
_destruct: function () {
for (var key in this) {
if (this.hasOwnProperty(key)) {
switch (typeof this[key]) {
case 'string':
this[key] = '';
break;
case 'object':
case 'function':
this[key] = null;
break;
}
}
}
Defined in
cocos/core/data/object.ts:352
Inherited from: Animation._getLocalBounds
If the component's bounding box is different from the node's, you can implement this method to supply
a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly.
Defined in
cocos/scene-graph/component.ts:684
protected _getRenderScene () : RenderScene
deprecated
Inherited from: RenderScene
Returns: RenderScene
Defined in
cocos/scene-graph/component.ts:218
deprecated
Inherited from: Animation._instantiate
Defined in
cocos/scene-graph/component.ts:419
Defined in
cocos/scene-graph/component.ts:405
Inherited from: Animation.lateUpdate
LateUpdate is called every frame, if the Component is enabled.
This is a lifecycle method. It may not be implemented in the super class.
You can only call its super class method inside it. It should not be called manually elsewhere.
This is a lifecycle method. It may not be implemented in the super class.
You can only call its super class method inside it. It should not be called manually elsewhere.
Defined in
cocos/scene-graph/component.ts:546
protected onRestore () : void
Inherited from: Animation.onRestore
onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs
an undo operation on this component.
If the component contains the "internal state", short for "temporary member variables which not included
in its CCClass properties", then you may need to implement this function.
The editor will call the getset accessors of your component to record/restore the component's state
for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
this function to manually synchronize your component's "internal states" with its public properties.
Once you implement this function, all the getset accessors of your component will not be called when
the user performs an undo/redo operation. Which means that only the properties with default value
will be recorded or restored by editor.
Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
to support the reset menu, you should manually synchronize your component's "internal states" with its
properties in this function. Once you implement this function, all the getset accessors of your component
will not be called during reset operation. Which means that only the properties with default value
will be reset by editor.
If the component contains the "internal state", short for "temporary member variables which not included
in its CCClass properties", then you may need to implement this function.
The editor will call the getset accessors of your component to record/restore the component's state
for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement
this function to manually synchronize your component's "internal states" with its public properties.
Once you implement this function, all the getset accessors of your component will not be called when
the user performs an undo/redo operation. Which means that only the properties with default value
will be recorded or restored by editor.
Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need
to support the reset menu, you should manually synchronize your component's "internal states" with its
properties in this function. Once you implement this function, all the getset accessors of your component
will not be called during reset operation. Which means that only the properties with default value
will be reset by editor.
This function is only called in editor mode.
Returns: void
Defined in
cocos/scene-graph/component.ts:726
Inherited from: Animation.update
Update is called every frame, if the Component is enabled.
This is a lifecycle method. It may not be implemented in the super class.
You can only call its super class method inside it. It should not be called manually elsewhere.
This is a lifecycle method. It may not be implemented in the super class.
You can only call its super class method inside it. It should not be called manually elsewhere.
Defined in
cocos/scene-graph/component.ts:529