using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlaySoundOnAnim : MonoBehaviour { public AudioClip m_Clip; public float m_Volume = 0.2f; public bool IsLoop = false; AudioSource m_AS; private void OnEnable() { if (m_Clip) m_AS = SoundInfo.Ins.Play_OneShot_byDistance(m_Clip, transform.position, m_Volume, IsLoop); } private void Update() { if (m_AS) { if (m_AS.isPlaying) { if (!DSUtil.CheckNull(NewGameUI.Ins) && NewGameUI.Ins.m_BangchiUI.isActiveAndEnabled) m_AS.volume = 0f; else m_AS.volume = SoundInfo.Ins.Get_Volume(transform.position, m_Volume); } else m_AS = null; } } private void OnDisable() { if (m_AS) m_AS.Stop(); m_AS = null; } }