forked from cgvr/DeltaVR
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -2551,7 +2551,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
target: 2
|
||||
target: 5
|
||||
--- !u!1 &3847096334227967442
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3539,8 +3539,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -2000.1, y: 34.7}
|
||||
m_SizeDelta: {x: 117.7, y: 49.6}
|
||||
m_AnchoredPosition: {x: -2404.8, y: 34.7}
|
||||
m_SizeDelta: {x: 220, y: 49.6}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &2306375091028476275
|
||||
CanvasRenderer:
|
||||
@@ -3570,7 +3570,7 @@ MonoBehaviour:
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: 'Music:'
|
||||
m_text: 'Voiceovers:'
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: d564a6b9a8a781b438125b614edcc297, type: 2}
|
||||
m_sharedMaterial: {fileID: 2467261418627247352, guid: d564a6b9a8a781b438125b614edcc297,
|
||||
@@ -4890,7 +4890,7 @@ GameObject:
|
||||
- component: {fileID: 9123126080211807181}
|
||||
- component: {fileID: 2844805864736818914}
|
||||
m_Layer: 5
|
||||
m_Name: Music Slider
|
||||
m_Name: Voiceover Slider
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
||||
@@ -8,7 +8,8 @@ public class SliderToVCA : MonoBehaviour
|
||||
Ambiences,
|
||||
Music,
|
||||
SFX,
|
||||
UI
|
||||
UI,
|
||||
Voiceovers
|
||||
}
|
||||
|
||||
public VCATarget target;
|
||||
@@ -40,6 +41,8 @@ private float GetInitialValueFromAudioManager()
|
||||
return AudioManager.Instance.SFXVolume;
|
||||
case VCATarget.UI:
|
||||
return AudioManager.Instance.UIVolume;
|
||||
case VCATarget.Voiceovers:
|
||||
return AudioManager.Instance.VoiceoverVolume;
|
||||
default:
|
||||
return 0.5f;
|
||||
}
|
||||
@@ -76,6 +79,10 @@ private float GetInitialValueFromAudioManager()
|
||||
case VCATarget.UI:
|
||||
AudioManager.Instance.SetUIVCA(value);
|
||||
break;
|
||||
|
||||
case VCATarget.Voiceovers:
|
||||
AudioManager.Instance.SetVoiceoverVCA(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,8 +184,6 @@ public class TutorialAudioListener : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void HandleGrab(XRGrabInteractable grab)
|
||||
{
|
||||
if (grab == null)
|
||||
|
||||
@@ -131,4 +131,4 @@ MonoBehaviour:
|
||||
PlayerOcclusionWidening: 1
|
||||
OcclusionLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_Bits: 268438528
|
||||
|
||||
Binary file not shown.
@@ -20,6 +20,7 @@ public class AudioManager : MonoBehaviour
|
||||
private VCA sfxVCA;
|
||||
private VCA uiVCA;
|
||||
private VCA ambienceVCA;
|
||||
private VCA voiceoverVCA;
|
||||
|
||||
[SerializeField]
|
||||
[Header("Volume")]
|
||||
@@ -40,6 +41,9 @@ public class AudioManager : MonoBehaviour
|
||||
public float UIVolume = 0.5f;
|
||||
[Range(0, 1)]
|
||||
|
||||
public float VoiceoverVolume = 0.5f;
|
||||
[Range(0, 1)]
|
||||
|
||||
private Bus masterBus;
|
||||
private Bus ambientBus;
|
||||
private Bus musicBus;
|
||||
@@ -63,6 +67,7 @@ public class AudioManager : MonoBehaviour
|
||||
// public static AudioManager instance;
|
||||
private static EventInstance musicEventInstance;
|
||||
|
||||
private EVENT_CALLBACK dialogueCallback;
|
||||
|
||||
// public access for the Singleton
|
||||
// and lazy instantiation if not exists
|
||||
@@ -108,18 +113,22 @@ public class AudioManager : MonoBehaviour
|
||||
_instance.sfxBus = RuntimeManager.GetBus("bus:/SFX");
|
||||
_instance.uiBus = RuntimeManager.GetBus("bus:/UI");
|
||||
|
||||
|
||||
_instance.masterVCA = RuntimeManager.GetVCA("vca:/Master");
|
||||
_instance.musicVCA = RuntimeManager.GetVCA("vca:/Music");
|
||||
_instance.ambienceVCA = RuntimeManager.GetVCA("vca:/Ambiences");
|
||||
_instance.sfxVCA = RuntimeManager.GetVCA("vca:/SFX");
|
||||
_instance.uiVCA = RuntimeManager.GetVCA("vca:/UI");
|
||||
_instance.voiceoverVCA = RuntimeManager.GetVCA("vca:/Voiceovers");
|
||||
|
||||
_instance.masterVCA.setVolume(_instance.MasterVolume);
|
||||
_instance.musicVCA.setVolume(_instance.MusicVolume);
|
||||
_instance.ambienceVCA.setVolume(_instance.AmbienceVolume);
|
||||
_instance.sfxVCA.setVolume(_instance.SFXVolume);
|
||||
_instance.uiVCA.setVolume(_instance.UIVolume);
|
||||
_instance.voiceoverVCA.setVolume(_instance.VoiceoverVolume);
|
||||
|
||||
_instance.dialogueCallback = new EVENT_CALLBACK(DialogueEventCallback);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -152,6 +161,11 @@ public class AudioManager : MonoBehaviour
|
||||
UIVolume = value;
|
||||
uiVCA.setVolume(UIVolume);
|
||||
}
|
||||
public void SetVoiceoverVCA(float value)
|
||||
{
|
||||
VoiceoverVolume = value;
|
||||
voiceoverVCA.setVolume(VoiceoverVolume);
|
||||
}
|
||||
|
||||
|
||||
private void Awake()
|
||||
@@ -207,7 +221,7 @@ public class AudioManager : MonoBehaviour
|
||||
EventInstance instance = RuntimeManager.CreateInstance(sound);
|
||||
RuntimeManager.AttachInstanceToGameObject(instance, go);
|
||||
instance.start();
|
||||
// instance.release();
|
||||
instance.release();
|
||||
|
||||
eventInstances.Add(instance);
|
||||
return instance;
|
||||
@@ -280,6 +294,106 @@ public class AudioManager : MonoBehaviour
|
||||
//=====//
|
||||
//=====//
|
||||
|
||||
public void PlayDialogue(string audioTableKey, GameObject emitter = null, float radioAmount = 0f)
|
||||
{
|
||||
|
||||
var dialogueEvent = FMODEvents.Instance.VoiceoverAll;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
// Assign the FMOD parameter value (in this case: Continous type)
|
||||
instance.setParameterByName("Radio", radioAmount);
|
||||
|
||||
// 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,
|
||||
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);
|
||||
|
||||
@@ -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,6 +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: 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 = "Chef/Ulrich_Terribly_Sorry1";
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
AudioManager.Instance.PlayDialogue(dialogueKey, gameObject, 0f);
|
||||
//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