Voiceline adding logic, fmod asset folder cleaning, fmod tweaks
This commit is contained in:
@@ -63,11 +63,6 @@ public class AudioManager : MonoBehaviour
|
||||
// public static AudioManager instance;
|
||||
private static EventInstance musicEventInstance;
|
||||
|
||||
// ===== Dialogue / Programmer Sounds =====
|
||||
|
||||
[SerializeField]
|
||||
private EventReference dialogueEvent;
|
||||
|
||||
private EVENT_CALLBACK dialogueCallback;
|
||||
|
||||
// public access for the Singleton
|
||||
@@ -289,26 +284,47 @@ public class AudioManager : MonoBehaviour
|
||||
//=====//
|
||||
//=====//
|
||||
|
||||
public void PlayDialogue(string audioTableKey)
|
||||
public void PlayDialogue(string audioTableKey, GameObject emitter = null)
|
||||
{
|
||||
if (!dialogueEvent.IsNull)
|
||||
{
|
||||
EventInstance instance = RuntimeManager.CreateInstance(dialogueEvent);
|
||||
|
||||
// Pin the string so FMOD can read it safely
|
||||
GCHandle stringHandle = GCHandle.Alloc(audioTableKey);
|
||||
instance.setUserData(GCHandle.ToIntPtr(stringHandle));
|
||||
var dialogueEvent = FMODEvents.Instance.VoiceoverAll;
|
||||
|
||||
instance.setCallback(dialogueCallback);
|
||||
instance.start();
|
||||
instance.release();
|
||||
}
|
||||
else
|
||||
if (dialogueEvent.IsNull)
|
||||
{
|
||||
Debug.LogWarning("Dialogue EventReference is not assigned!");
|
||||
return;
|
||||
}
|
||||
|
||||
EventInstance instance = RuntimeManager.CreateInstance(dialogueEvent);
|
||||
|
||||
if (emitter != null)
|
||||
{
|
||||
RuntimeManager.AttachInstanceToGameObject(instance, emitter);
|
||||
instance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(emitter.gameObject));
|
||||
}
|
||||
|
||||
// Pin the key for programmer sound callback
|
||||
GCHandle stringHandle = GCHandle.Alloc(audioTableKey);
|
||||
instance.setUserData(GCHandle.ToIntPtr(stringHandle));
|
||||
|
||||
// Set the callback for programmer sounds
|
||||
instance.setCallback(dialogueCallback);
|
||||
|
||||
// Add occlusion if available on the emitter
|
||||
if (emitter != null)
|
||||
{
|
||||
FirstPersonOcclusion occlusion = emitter.GetComponent<FirstPersonOcclusion>();
|
||||
if (occlusion != null)
|
||||
{
|
||||
occlusion.InitialiseWithInstance(instance);
|
||||
}
|
||||
}
|
||||
|
||||
instance.start();
|
||||
instance.release();
|
||||
}
|
||||
|
||||
|
||||
[AOT.MonoPInvokeCallback(typeof(EVENT_CALLBACK))]
|
||||
private static FMOD.RESULT DialogueEventCallback(
|
||||
EVENT_CALLBACK_TYPE type,
|
||||
|
||||
@@ -3,6 +3,9 @@ using UnityEngine;
|
||||
|
||||
public class FMODEvents : MonoBehaviour
|
||||
{
|
||||
[field: Header("Voiceline FMOD Programmer Event")]
|
||||
[field: SerializeField] public EventReference VoiceoverAll { get; private set; }
|
||||
|
||||
[field: Header("Musical Ambiences")]
|
||||
|
||||
[field: SerializeField] public EventReference Kosmos { get; private set; }
|
||||
@@ -19,7 +22,7 @@ public class FMODEvents : MonoBehaviour
|
||||
[field: SerializeField] public EventReference BowGrab { get; private set; }
|
||||
[field: SerializeField] public EventReference Spray { get; private set; }
|
||||
[field: SerializeField] public EventReference Coughing { get; private set; }
|
||||
[field: SerializeField] public EventReference MyNewSoundEffect { get; private set; }
|
||||
//[field: SerializeField] public EventReference MyNewSoundEffect { get; private set; }
|
||||
|
||||
[field: Header("CAR")]
|
||||
[field: SerializeField] public EventReference DoorOpen { get; private set; }
|
||||
|
||||
13
Assets/_PROJECT/Scripts/Audio/VoiceoverTester.cs
Normal file
13
Assets/_PROJECT/Scripts/Audio/VoiceoverTester.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class VoiceoverTester : MonoBehaviour
|
||||
{
|
||||
//[Tooltip("Audio Table key")]
|
||||
public string dialogueKey = "Professor/Madis_Printing2";
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
AudioManager.Instance.PlayDialogue(dialogueKey, gameObject);
|
||||
//Debug.LogError("Voiceline played (in 3D)");
|
||||
}
|
||||
}
|
||||
11
Assets/_PROJECT/Scripts/Audio/VoiceoverTester.cs.meta
Normal file
11
Assets/_PROJECT/Scripts/Audio/VoiceoverTester.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e77f6976a4505294797905646ff02a8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user