Slash-The-Hordes/assets/Scripts/Utils/UIButtonAudioPlayer.ts
2022-12-22 13:26:43 +01:00

18 lines
613 B
TypeScript

import { Component, _decorator } from "cc";
import { AppRoot } from "../AppRoot/AppRoot";
import { UIButton } from "../Services/UI/Button/UIButton";
const { ccclass, property } = _decorator;
@ccclass("UIButtonAudioPlayer")
export class UIButtonAudioPlayer extends Component {
@property(UIButton) private button: UIButton;
public start(): void {
this.button.InteractedEvent.on(this.playButtonClick, this);
}
private playButtonClick(): void {
const audioClip = AppRoot.Instance.GameAssets.AudioAssets.buttonClick;
AppRoot.Instance.AudioPlayer.playSound(audioClip);
}
}