Files
modular-vr/Assets/Station46/Scripts/ButtonSound.cs
2023-05-16 15:01:06 +02:00

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();
}
};
}
}
}