17 lines
433 B
TypeScript
17 lines
433 B
TypeScript
|
|
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);
|
|
}
|
|
}
|
|
}
|