holopy3/Assets/Scripts/AudioHolder.cs
2020-12-10 15:25:12 +01:00

35 lines
596 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioHolder : MonoBehaviour
{
AudioSource SoundEmitter;
private void OnEnable()
{
// Add delegate
Trigger.OnGlassTriggered += PlaySound;
}
private void OnDisable()
{
// Remove delegate
Trigger.OnGlassTriggered += PlaySound;
}
// Start is called before the first frame update
void Start()
{
SoundEmitter = GetComponent<AudioSource>();
}
private void PlaySound()
{
SoundEmitter.Play();
}
}