Colliders with Probuilder, FMOD Programmer Instrument API code start
This commit is contained in:
@@ -9,12 +9,12 @@ public class CarAudioController : MonoBehaviour
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
//Debug.LogError("AUDIO MANAGER:");
|
||||
//Debug.LogError(AudioManager.Instance);
|
||||
//Debug.LogError("FMOD EVENTS INSTANCE:");
|
||||
//Debug.LogError(FMODEvents.Instance);
|
||||
//Debug.LogError("Car Simple Driving:");
|
||||
//Debug.LogError(FMODEvents.Instance.BoltCarSimpleDriving);
|
||||
Debug.LogError("AUDIO MANAGER:");
|
||||
Debug.LogError(AudioManager.Instance);
|
||||
Debug.LogError("FMOD EVENTS INSTANCE:");
|
||||
Debug.LogError(FMODEvents.Instance);
|
||||
Debug.LogError("Car Simple Driving:");
|
||||
Debug.LogError(FMODEvents.Instance.BoltCarSimpleDriving);
|
||||
carMovementInstance = AudioManager.Instance.CreateInstance(FMODEvents.Instance.CarModulatedDriving);
|
||||
carStopInstance = AudioManager.Instance.CreateInstance(FMODEvents.Instance.BoltCarStopSound);
|
||||
|
||||
|
||||
Binary file not shown.
@@ -63,6 +63,12 @@ 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
|
||||
// and lazy instantiation if not exists
|
||||
@@ -121,6 +127,9 @@ public class AudioManager : MonoBehaviour
|
||||
_instance.sfxVCA.setVolume(_instance.SFXVolume);
|
||||
_instance.uiVCA.setVolume(_instance.UIVolume);
|
||||
|
||||
_instance.dialogueCallback = new EVENT_CALLBACK(DialogueEventCallback);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void SetMasterVCA(float value)
|
||||
@@ -280,6 +289,82 @@ public class AudioManager : MonoBehaviour
|
||||
//=====//
|
||||
//=====//
|
||||
|
||||
public void PlayDialogue(string audioTableKey)
|
||||
{
|
||||
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));
|
||||
|
||||
instance.setCallback(dialogueCallback);
|
||||
instance.start();
|
||||
instance.release();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Dialogue EventReference is not assigned!");
|
||||
}
|
||||
}
|
||||
|
||||
[AOT.MonoPInvokeCallback(typeof(EVENT_CALLBACK))]
|
||||
private static FMOD.RESULT DialogueEventCallback(
|
||||
EVENT_CALLBACK_TYPE type,
|
||||
IntPtr instancePtr,
|
||||
IntPtr parameterPtr)
|
||||
{
|
||||
EventInstance instance = new EventInstance(instancePtr);
|
||||
|
||||
instance.getUserData(out IntPtr stringPtr);
|
||||
GCHandle stringHandle = GCHandle.FromIntPtr(stringPtr);
|
||||
string key = stringHandle.Target as string;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EVENT_CALLBACK_TYPE.CREATE_PROGRAMMER_SOUND:
|
||||
{
|
||||
var parameter = Marshal.PtrToStructure<PROGRAMMER_SOUND_PROPERTIES>(parameterPtr);
|
||||
|
||||
FMOD.Studio.SOUND_INFO soundInfo;
|
||||
var result = RuntimeManager.StudioSystem.getSoundInfo(key, out soundInfo);
|
||||
if (result != FMOD.RESULT.OK)
|
||||
break;
|
||||
|
||||
FMOD.Sound sound;
|
||||
RuntimeManager.CoreSystem.createSound(
|
||||
soundInfo.name_or_data,
|
||||
soundInfo.mode | FMOD.MODE.CREATECOMPRESSEDSAMPLE,
|
||||
ref soundInfo.exinfo,
|
||||
out sound
|
||||
);
|
||||
|
||||
parameter.sound = sound.handle;
|
||||
parameter.subsoundIndex = soundInfo.subsoundindex;
|
||||
Marshal.StructureToPtr(parameter, parameterPtr, false);
|
||||
break;
|
||||
}
|
||||
|
||||
case EVENT_CALLBACK_TYPE.DESTROY_PROGRAMMER_SOUND:
|
||||
{
|
||||
var parameter = Marshal.PtrToStructure<PROGRAMMER_SOUND_PROPERTIES>(parameterPtr);
|
||||
var sound = new FMOD.Sound(parameter.sound);
|
||||
sound.release();
|
||||
break;
|
||||
}
|
||||
|
||||
case EVENT_CALLBACK_TYPE.DESTROYED:
|
||||
{
|
||||
// Release pinned string
|
||||
stringHandle.Free();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return FMOD.RESULT.OK;
|
||||
}
|
||||
|
||||
public void StopSFX()
|
||||
{
|
||||
sfxBus.stopAllEvents(FMOD.Studio.STOP_MODE.IMMEDIATE);
|
||||
|
||||
@@ -19,6 +19,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: Header("CAR")]
|
||||
[field: SerializeField] public EventReference DoorOpen { get; private set; }
|
||||
|
||||
Reference in New Issue
Block a user