43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using UnityEngine.EventSystems;
|
|
|
|
namespace Superlazy.UI
|
|
{
|
|
public class SLUISound : UIBehaviour
|
|
{
|
|
public string onSound = "SoundEffect/SE_UI_message";
|
|
public string offSound = "SoundEffect/SE_UI_message";
|
|
|
|
public string loopSound = string.Empty;
|
|
public string loopSoundTag = string.Empty;
|
|
|
|
protected override void OnEnable()
|
|
{
|
|
base.OnEnable();
|
|
|
|
if (onSound != string.Empty)
|
|
{
|
|
SLSound.PlaySound(onSound, "UI", false, false, true, 0.5f);
|
|
}
|
|
|
|
if (loopSound != string.Empty)
|
|
{
|
|
SLSound.PlaySound(loopSound, loopSoundTag, true, true, true, 0.5f);
|
|
}
|
|
}
|
|
|
|
protected override void OnDisable()
|
|
{
|
|
base.OnEnable();
|
|
|
|
if (offSound != string.Empty)
|
|
{
|
|
SLSound.PlaySound(offSound, "UI", false, false, true, 0.5f);
|
|
}
|
|
|
|
if (loopSound != string.Empty)
|
|
{
|
|
SLSound.StopSound(loopSoundTag);
|
|
}
|
|
}
|
|
}
|
|
} |