mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
pause animation playing when unenabled (#2718)
add animation warn id fix animation bug 添加注释 英文注释
This commit is contained in:
@@ -262,6 +262,14 @@ var Animation = cc.Class({
|
||||
animator.playState(state, startTime);
|
||||
}
|
||||
|
||||
// Animation cannot be played when the component is not enabledInHierarchy.
|
||||
// That would cause an error for the animation lost the reference after destroying the node.
|
||||
// If users play the animation when the component is not enabledInHierarchy,
|
||||
// we pause the animator here so that it will automatically resume the animation when users enable the component.
|
||||
if (!this.enabledInHierarchy) {
|
||||
animator.pause();
|
||||
}
|
||||
|
||||
this.currentClip = state.clip;
|
||||
}
|
||||
return state;
|
||||
|
||||
Reference in New Issue
Block a user