2024-12-15 01:39:39 +00:00
|
|
|
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()
|
|
|
|
|
{
|
2024-12-28 00:20:09 +00:00
|
|
|
if (m_Clip && !DSUtil.CheckNull(SoundInfo.Ins))
|
2024-12-15 01:39:39 +00:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|