24 lines
633 B
TypeScript
Raw Normal View History

2023-02-22 09:50:51 +08:00
import { _decorator, Component, Node, animation } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('UIAnimation')
export class ui_animation extends Component {
_graph: animation.AnimationController | undefined | null;
onEnable () {
this._graph = this.getComponent(animation.AnimationController);
if (this._graph === null) {
throw new Error(`${this.node.name} node can not find AnimationController.`);
}
this.node.on('set_anim', this.play, this);
}
play (key: string, value: boolean | number) {
this._graph!.setValue(key, value);
}
}