holopy3/Assets/Scripts/AudioHolder.cs

36 lines
596 B
C#
Raw Normal View History

2020-12-10 14:25:12 +00:00
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();
}
}