|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using FMODUnity;
|
|
|
|
using FMOD.Studio;
|
|
|
|
|
|
|
|
public class AudioManager : MonoBehaviour
|
|
|
|
{
|
|
|
|
public static AudioManager instance { get; private set; }
|
|
|
|
[SerializeField] public EventReference m_Soundtrack;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
if (instance != null)
|
|
|
|
Debug.LogError("Found more than one Audio Manager in the scene");
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
StartSoundtrack();
|
|
|
|
Time.timeScale = .75f;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void StartSoundtrack()
|
|
|
|
{
|
|
|
|
if (!m_Soundtrack.IsNull)
|
|
|
|
{
|
|
|
|
//RuntimeManager.PlayOneShot(m_Soundtrack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public EventInstance PlaySound(EventReference sound)
|
|
|
|
{
|
|
|
|
EventInstance soundInst = RuntimeManager.CreateInstance(sound);
|
|
|
|
soundInst.start();
|
|
|
|
return soundInst;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Physic's based sounds
|
|
|
|
public void PlayOneShotAttached(EventReference sound, GameObject obj, float force)
|
|
|
|
{
|
|
|
|
RuntimeManager.PlayOneShotAttached(sound, obj, force, 0.1f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PlayOneShotAttachedBreathing(EventReference sound, GameObject obj, float force)
|
|
|
|
{
|
|
|
|
RuntimeManager.PlayOneShotAttached(sound, obj, force, 0.3f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void StopSound(EventInstance soundInst)
|
|
|
|
{
|
|
|
|
soundInst.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
|
|
|
|
soundInst.release();
|
|
|
|
soundInst.clearHandle();
|
|
|
|
}
|
|
|
|
}
|