AudioSourceParent.cs 817 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using UnityEngine;
  3. public class AudioSourceParent : MonoBehaviour
  4. {
  5. private AudioSourceMgr AudioMan
  6. {
  7. get
  8. {
  9. return this.m_AudioMan;
  10. }
  11. }
  12. public void AttachVoice(Transform f_trParent, AudioSourceParent.dgOnDettach f_dgDetattchCallBack)
  13. {
  14. this.m_dgOnDetattch = f_dgDetattchCallBack;
  15. this.m_AudioMan = GameMain.Instance.SoundMgr.AllocVoice(f_trParent, true);
  16. }
  17. public void OnDestroy()
  18. {
  19. if (this.m_dgOnDetattch != null)
  20. {
  21. this.m_dgOnDetattch(this);
  22. this.m_dgOnDetattch = null;
  23. }
  24. if (this.m_AudioMan != null)
  25. {
  26. GameMain.Instance.SoundMgr.FreeVoice(this.m_AudioMan, false);
  27. this.m_AudioMan = null;
  28. }
  29. }
  30. public AudioSourceMgr m_AudioMan;
  31. private AudioSourceParent.dgOnDettach m_dgOnDetattch;
  32. public delegate void dgOnDettach(AudioSourceParent f_asp);
  33. }