Prefeb_Unit.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using CrossgateToolkit;
  5. using UnityEngine;
  6. public class Prefeb_Unit : MonoBehaviour
  7. {
  8. public AnimePlayer animePlayer;
  9. public RectTransform RectTransform;
  10. private void Awake()
  11. {
  12. RectTransform = GetComponent<RectTransform>();
  13. // 可以监听动画播放帧中的音频事件并播放音效
  14. animePlayer.onAudioListener = (audioID) =>
  15. {
  16. // 播放音效
  17. // 1.获取AudioClip并自行交给AudioSource播放,推荐背景音乐等长时间循环音频交给AudioSource播放
  18. // AudioClip audioClip = CrossgateToolkit.Audio.Play([Your AudioSource],Audio.Type.BGM,audioID);
  19. // 2.直接播放音效,推荐技能、人物等一次性特效音频直接交给Audio类播放和管控,即不指定AudioSource
  20. CrossgateToolkit.Audio.Play(null,Audio.Type.EFFECT,audioID);
  21. };
  22. }
  23. // Start is called before the first frame update
  24. void Start()
  25. {
  26. }
  27. // Update is called once per frame
  28. void Update()
  29. {
  30. }
  31. }