UIButton.ts 640 B

123456789101112131415161718192021222324
  1. import { Node,_decorator,AudioClip, Button } from "cc";
  2. import { GameMng } from "../GameMng";
  3. import AudioMng from "./AudioMng";
  4. const { ccclass, property } = _decorator;
  5. @ccclass('UIButton')
  6. export class UIButton {
  7. public static BindClick(node: Node, func: Function, obj: any, audioClip: AudioClip = GameMng.Instance.buttonclick): void {
  8. if(node.getComponent(Button)==null){
  9. console.log(node.name,"null")
  10. }else{
  11. node.on('click', () => {
  12. func.call(obj);
  13. AudioMng.Instance.PlaySoundByName(audioClip);
  14. }, obj);
  15. }
  16. }
  17. }