revival/game/Assets/Scripts/Audio/SFXTrigger.cs

26 lines
576 B
C#
Raw Permalink Normal View History

2021-05-17 18:29:18 +02:00
using FMOD.Studio;
using FMODUnity;
using UnityEngine;
using STOP_MODE = FMOD.Studio.STOP_MODE;
public class SFXTrigger : MonoBehaviour
{
[SerializeField]
[EventRef]
private string _sfx;
private EventInstance _sfxInstance;
void Awake()
{
_sfxInstance = RuntimeManager.CreateInstance( _sfx );
RuntimeManager.AttachInstanceToGameObject( _sfxInstance, transform, (Rigidbody)null );
}
public void Trigger()
{
_sfxInstance.stop(STOP_MODE.IMMEDIATE);
_sfxInstance.start();
}
}