27 lines
597 B
C#
27 lines
597 B
C#
using NaughtyAttributes;
|
|
using UnityEngine;
|
|
|
|
namespace Station46.Scripts
|
|
{
|
|
[RequireComponent(typeof(Button))]
|
|
public class ButtonSound : MonoBehaviour
|
|
{
|
|
[BoxGroup("Internal")] public AudioSource audioSource;
|
|
|
|
private void Awake()
|
|
{
|
|
audioSource.loop = false;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
GetComponent<Button>().ButtonEvent += (_, type) =>
|
|
{
|
|
if (type == ButtonEventType.Pressed)
|
|
{
|
|
audioSource.Play();
|
|
}
|
|
};
|
|
}
|
|
}
|
|
} |