2 working sounds, updated scripts, fmod events
This commit is contained in:
@@ -7,6 +7,8 @@ using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
using STOP_MODE = FMOD.Studio.STOP_MODE;
|
||||
|
||||
public class AudioManager : MonoBehaviour
|
||||
{
|
||||
[Header("Volume")]
|
||||
@@ -133,6 +135,48 @@ public class AudioManager : MonoBehaviour
|
||||
Debug.LogWarning("EventReference is null, ignoring...");
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayOneShot3D(EventReference sound, Vector3 position)
|
||||
{
|
||||
if (!IsEventReferenceValid(sound))
|
||||
{
|
||||
Debug.LogWarning("Tried to play invalid FMOD event (3D)");
|
||||
return;
|
||||
}
|
||||
|
||||
RuntimeManager.PlayOneShot(sound, position);
|
||||
}
|
||||
|
||||
public EventInstance PlayAttachedInstance(EventReference sound, GameObject go)
|
||||
{
|
||||
if (!IsEventReferenceValid(sound))
|
||||
{
|
||||
Debug.LogWarning("Tried to play invalid FMOD event (attached)");
|
||||
return default;
|
||||
}
|
||||
|
||||
EventInstance instance = RuntimeManager.CreateInstance(sound);
|
||||
RuntimeManager.AttachInstanceToGameObject(instance, go);
|
||||
instance.start();
|
||||
|
||||
eventInstances.Add(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void StopInstance(EventInstance instance, STOP_MODE mode = STOP_MODE.ALLOWFADEOUT)
|
||||
{
|
||||
if (!instance.isValid()) return;
|
||||
instance.stop(mode);
|
||||
instance.release();
|
||||
eventInstances.Remove(instance);
|
||||
}
|
||||
|
||||
public void SetParameter(EventInstance instance, string parameterName, float value)
|
||||
{
|
||||
if (!instance.isValid()) return;
|
||||
instance.setParameterByName(parameterName, value);
|
||||
}
|
||||
|
||||
public void InitializeMusic(EventReference musicEventReference)
|
||||
{
|
||||
if (musicEventReference.Guid == nullGuid)
|
||||
|
||||
Reference in New Issue
Block a user