JM_KA/assets/Script/Engine/Component/Animation/AnimationAutoPlay.ts

17 lines
433 B
TypeScript
Raw Normal View History

2022-08-26 16:48:17 +08:00
const { ccclass, requireComponent, menu } = cc._decorator;
@ccclass
@menu("Plug-in/Animation/AnimationAutoPlay")
@requireComponent(cc.Animation)
export default class AnimationAutoPlay extends cc.Component {
onEnable() {
let anim = this.getComponent(cc.Animation);
if (anim != null) {
let animationState = anim.play();
anim.sample(animationState.name);
}
}
}