implementation of drecon in unity 2022 lts forked from: https://github.com/joanllobera/marathon-envs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.5 KiB

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, 1f, 0.01f);
Debug.Log(force);
}
public void PlayOneShotAttachedBreathing(EventReference sound, GameObject obj, float force)
{
//RuntimeManager.PlayOneShotAttached(sound, obj, force, 0.05f);
}
public void StopSound(EventInstance soundInst)
{
soundInst.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
soundInst.release();
soundInst.clearHandle();
}
}