From 109551017da8b274943f4e5cd6b45d215ac6d980 Mon Sep 17 00:00:00 2001 From: Hugo Le Bolloc'h Date: Fri, 22 May 2026 00:21:12 +0200 Subject: [PATCH] wip : scene timing with music & early custom cue listener --- Assets/_Content/Scenes/BodiesInWater.unity | 34 +-- Assets/_Content/Scenes/HouseOfLeaves.unity | 2 +- Assets/_Content/Scenes/Samyaza.unity | 2 +- .../Hugo/HugoTestScene.unity | 202 ++++++++++++------ .../Hugo/Theatre_TestMusic.unity | 68 +++++- .../Core/Audio/Audio_MusicCueListener.cs | 64 ++++++ .../Core/Audio/Audio_MusicCueListener.cs.meta | 2 + .../Scripts/Core/Audio/MusicCueLogger.cs | 35 --- .../Scripts/Core/Audio/MusicCueLogger.cs.meta | 2 - .../Mac/Event/Play_DemoMusic.bnk | 4 +- .../Mac/Event/Play_DemoMusic.json | 14 +- .../Mac/Event/Play_MarkerLane.bnk | 2 +- .../Mac/Event/Play_MarkerLane.json | 4 +- 13 files changed, 299 insertions(+), 136 deletions(-) create mode 100644 Assets/_Content/Scripts/Core/Audio/Audio_MusicCueListener.cs create mode 100644 Assets/_Content/Scripts/Core/Audio/Audio_MusicCueListener.cs.meta delete mode 100644 Assets/_Content/Scripts/Core/Audio/MusicCueLogger.cs delete mode 100644 Assets/_Content/Scripts/Core/Audio/MusicCueLogger.cs.meta diff --git a/Assets/_Content/Scenes/BodiesInWater.unity b/Assets/_Content/Scenes/BodiesInWater.unity index 497ad18d..80856614 100644 --- a/Assets/_Content/Scenes/BodiesInWater.unity +++ b/Assets/_Content/Scenes/BodiesInWater.unity @@ -162,7 +162,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -215,7 +215,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -495,7 +495,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -548,7 +548,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -601,7 +601,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -654,7 +654,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -707,7 +707,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -760,7 +760,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -813,7 +813,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -947,7 +947,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -1000,7 +1000,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -1191,7 +1191,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -1261,7 +1261,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 0 Duration: 30 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0, z: 7} Rotation: {x: 0, y: 0, z: 0} Scale: {x: 0, y: 0, z: 0} @@ -1331,7 +1331,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} @@ -1389,7 +1389,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0, z: 0} Rotation: {x: 6, y: 2, z: 8} Scale: {x: 0, y: 0, z: 0} @@ -1486,7 +1486,7 @@ MonoBehaviour: _tolerance: 0.5 _duration: 1 _execution: 1 - _delay: 30 + _delay: 14.7 _onTrigger: m_PersistentCalls: m_Calls: [] @@ -1563,7 +1563,7 @@ MonoBehaviour: PlayOnAwake: 1 RandomOffset: 1 Duration: 4 - TimeOffset: 0 + CycleOffset: 0 Translation: {x: 0, y: 0.2, z: 0} Rotation: {x: 3, y: 5, z: 2} Scale: {x: 0, y: 0, z: 0} diff --git a/Assets/_Content/Scenes/HouseOfLeaves.unity b/Assets/_Content/Scenes/HouseOfLeaves.unity index 9313f2bc..663039a9 100644 --- a/Assets/_Content/Scenes/HouseOfLeaves.unity +++ b/Assets/_Content/Scenes/HouseOfLeaves.unity @@ -1199,7 +1199,7 @@ MonoBehaviour: _tolerance: 0.5 _duration: 1 _execution: 1 - _delay: 20 + _delay: 14.9 _onTrigger: m_PersistentCalls: m_Calls: [] diff --git a/Assets/_Content/Scenes/Samyaza.unity b/Assets/_Content/Scenes/Samyaza.unity index 039d1f04..27c48440 100644 --- a/Assets/_Content/Scenes/Samyaza.unity +++ b/Assets/_Content/Scenes/Samyaza.unity @@ -681,7 +681,7 @@ MonoBehaviour: _tolerance: 0.5 _duration: 1 _execution: 1 - _delay: 20 + _delay: 15 _onTrigger: m_PersistentCalls: m_Calls: [] diff --git a/Assets/_Content/Scenes/Testing/Sound Design Test/Hugo/HugoTestScene.unity b/Assets/_Content/Scenes/Testing/Sound Design Test/Hugo/HugoTestScene.unity index 3702fd51..2ced0281 100644 --- a/Assets/_Content/Scenes/Testing/Sound Design Test/Hugo/HugoTestScene.unity +++ b/Assets/_Content/Scenes/Testing/Sound Design Test/Hugo/HugoTestScene.unity @@ -119,6 +119,79 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &100423306 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 100423309} + - component: {fileID: 100423308} + - component: {fileID: 100423307} + m_Layer: 0 + m_Name: GameObject + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &100423307 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 100423306} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4ccb80e2899444642bdbf406a3c31f7b, type: 3} + m_Name: + m_EditorClassIdentifier: AK.Wwise.Unity.MonoBehaviour::AkGameObj + m_listeners: + initialListenerList: [] + useDefaultListeners: 1 + isEnvironmentAware: 1 + isStaticObject: 0 + usePositionOffsetData: 0 + m_positionOffsetData: + KeepMe: 0 + positionOffset: {x: 0, y: 0, z: 0} + scalingFactor: 1 + m_posOffsetData: {fileID: 0} + listenerMask: 1 +--- !u!114 &100423308 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 100423306} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 57e4af8a70aa9904da2b35504ad63407, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::Audio_MusicCueListener + musicEvent: + idInternal: 0 + valueGuidInternal: + WwiseObjectReference: {fileID: 11400000, guid: 9dc07a762aed4954bbd6034fe5032240, type: 2} +--- !u!4 &100423309 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 100423306} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -2.07226, y: 3.29875, z: -5.01629} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &245714134 GameObject: m_ObjectHideFlags: 0 @@ -421,6 +494,63 @@ MonoBehaviour: groupIdInternal: 0 groupGuidInternal: WwiseObjectReference: {fileID: 11400000, guid: 90b25d313fd10fe4bb34ce68d987f60e, type: 2} +--- !u!1001 &727419957 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_LocalPosition.x + value: -1.80955 + objectReference: {fileID: 0} + - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_LocalPosition.y + value: 2.88452 + objectReference: {fileID: 0} + - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_LocalPosition.z + value: -4.28006 + objectReference: {fileID: 0} + - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6521978618824486866, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_Name + value: AudioManager + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} --- !u!1 &935580408 stripped GameObject: m_CorrespondingSourceObject: {fileID: 8162540767767967414, guid: 524ca0dabcf93844ea5f981410f44310, type: 3} @@ -1623,75 +1753,6 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: aec729894f9f57b46b671ad6de6dfd31, type: 3} ---- !u!1001 &1671855845641723936 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_LocalPosition.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4908846766475971086, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: PlayMusic.WwiseObjectReference - value: - objectReference: {fileID: 11400000, guid: 4303be4199a066247b73a540c1bf916a, type: 2} - - target: {fileID: 4908846766475971086, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: StopMusic.WwiseObjectReference - value: - objectReference: {fileID: 11400000, guid: 30074da3ee405904689ea5fcccb862bb, type: 2} - - target: {fileID: 6521978618824486866, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_Name - value: AudioManager - objectReference: {fileID: 0} - - target: {fileID: 6521978618824486866, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} --- !u!1001 &2118492718844646720 PrefabInstance: m_ObjectHideFlags: 0 @@ -1778,7 +1839,8 @@ SceneRoots: - {fileID: 245714138} - {fileID: 1586552169} - {fileID: 661203445} - - {fileID: 1671855845641723936} - {fileID: 1250423863045520849} - {fileID: 2118492718844646720} - {fileID: 1488412446344103320} + - {fileID: 727419957} + - {fileID: 100423309} diff --git a/Assets/_Content/Scenes/Testing/Sound Design Test/Hugo/Theatre_TestMusic.unity b/Assets/_Content/Scenes/Testing/Sound Design Test/Hugo/Theatre_TestMusic.unity index 63e58096..d36de248 100644 --- a/Assets/_Content/Scenes/Testing/Sound Design Test/Hugo/Theatre_TestMusic.unity +++ b/Assets/_Content/Scenes/Testing/Sound Design Test/Hugo/Theatre_TestMusic.unity @@ -765,6 +765,10 @@ PrefabInstance: propertyPath: m_Name value: AudioManager objectReference: {fileID: 0} + - target: {fileID: 6521978618824486866, guid: 61f7fe4128138164295ef34aae4f6659, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -2549,7 +2553,7 @@ PrefabInstance: m_Modifications: - target: {fileID: 1836997810253213181, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3} propertyPath: m_Enabled - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 1836997810253213181, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3} propertyPath: m_listeners.useDefaultListeners @@ -2565,7 +2569,7 @@ PrefabInstance: objectReference: {fileID: 2146278993} - target: {fileID: 1984479600479780032, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3} propertyPath: m_Enabled - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 3452915509921429875, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3} propertyPath: m_IsActive @@ -11181,6 +11185,63 @@ MonoBehaviour: m_EditorClassIdentifier: Assembly-CSharp::PortalShader _id: 0 _oval: 0 +--- !u!1 &1981624589 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1981624591} + - component: {fileID: 1981624590} + m_Layer: 0 + m_Name: WwiseGlobal + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1981624590 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1981624589} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ca8082afa1214454c828fd22641b8692, type: 3} + m_Name: + m_EditorClassIdentifier: AK.Wwise.Unity.MonoBehaviour::AkInitializer + InitializationSettings: {fileID: 11400000, guid: de5fd82fbf79ed247b9046e375a4b249, type: 2} + basePath: + language: + defaultPoolSize: 0 + lowerPoolSize: 0 + streamingPoolSize: 0 + memoryCutoffThreshold: 0 + monitorPoolSize: 0 + monitorQueuePoolSize: 0 + callbackManagerBufferSize: 0 + spatialAudioPoolSize: 0 + maxSoundPropagationDepth: 0 + engineLogging: 0 +--- !u!4 &1981624591 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1981624589} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1982960622 GameObject: m_ObjectHideFlags: 0 @@ -11649,7 +11710,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 642044301} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 0} - m_Enabled: 0 + m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: a835ee92b0863c9459a0f816c5ff62ac, type: 3} m_Name: @@ -15661,3 +15722,4 @@ SceneRoots: - {fileID: 506323320} - {fileID: 710358848} - {fileID: 91432472} + - {fileID: 1981624591} diff --git a/Assets/_Content/Scripts/Core/Audio/Audio_MusicCueListener.cs b/Assets/_Content/Scripts/Core/Audio/Audio_MusicCueListener.cs new file mode 100644 index 00000000..e08a112e --- /dev/null +++ b/Assets/_Content/Scripts/Core/Audio/Audio_MusicCueListener.cs @@ -0,0 +1,64 @@ +using UnityEngine; + +// Requires the Wwise Unity Integration package in your project. +public class Audio_MusicCueListener : MonoBehaviour +{ + // Drag your Wwise event asset here in the Inspector, + // or assign the event name as a string (see PostEvent overload below). + [SerializeField] private AK.Wwise.Event musicEvent; + + private uint _playingId; + + private void Start() + { + PlayMusicWithCueCallbacks(); + } + + private void PlayMusicWithCueCallbacks() + { + // AK_MusicSyncUserCue fires every time a Custom Cue marker is hit. + // Combine with other flags using | if you need beat/bar callbacks too. + uint callbackFlags = (uint)(AkCallbackType.AK_MusicSyncUserCue + | AkCallbackType.AK_EndOfEvent); + + _playingId = musicEvent.Post( + gameObject, + callbackFlags, + OnMusicCallback + ); + + if (_playingId == AkUnitySoundEngine.AK_INVALID_PLAYING_ID) + { + Debug.LogError("[MusicCuePlayer] Failed to post Wwise event. " + + "Check the event name and AkGameObj component."); + } + else + { + Debug.Log($"[MusicCuePlayer] Music started — playing ID: {_playingId}"); + } + } + + // Called by Wwise on the main thread for each registered callback type. + private void OnMusicCallback(object cookie, AkCallbackType type, AkCallbackInfo info) + { + switch (type) + { + case AkCallbackType.AK_MusicSyncUserCue: + var cueInfo = (AkMusicSyncCallbackInfo)info; + Debug.Log($"[MusicCuePlayer] Cue reached: '{cueInfo.userCueName}'"); + // Hook your game logic here, e.g.: + // OnCueReached(cueInfo.userCueName); + break; + + case AkCallbackType.AK_EndOfEvent: + Debug.Log("[MusicCuePlayer] Music event ended."); + break; + } + } + + private void OnDestroy() + { + // Stop the sound cleanly when this object is destroyed. + AkUnitySoundEngine.StopPlayingID(_playingId, 500); // 500 ms fade-out + } +} diff --git a/Assets/_Content/Scripts/Core/Audio/Audio_MusicCueListener.cs.meta b/Assets/_Content/Scripts/Core/Audio/Audio_MusicCueListener.cs.meta new file mode 100644 index 00000000..1d271989 --- /dev/null +++ b/Assets/_Content/Scripts/Core/Audio/Audio_MusicCueListener.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 57e4af8a70aa9904da2b35504ad63407 \ No newline at end of file diff --git a/Assets/_Content/Scripts/Core/Audio/MusicCueLogger.cs b/Assets/_Content/Scripts/Core/Audio/MusicCueLogger.cs deleted file mode 100644 index 393d7041..00000000 --- a/Assets/_Content/Scripts/Core/Audio/MusicCueLogger.cs +++ /dev/null @@ -1,35 +0,0 @@ -using UnityEngine; - -public class MusicCueLogger : MonoBehaviour -{ - [SerializeField] private AK.Wwise.Event musicEvent; - - private uint _playingId; - - private void Start() - { - _playingId = musicEvent.Post( - gameObject, - (uint)AkCallbackType.AK_MusicSyncUserCue, - OnMusicSync - ); - } - - private void OnMusicSync(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) - { - if (in_type != AkCallbackType.AK_MusicSyncUserCue) - return; - - var cueInfo = in_info as AkMusicSyncCallbackInfo; - if (cueInfo == null) - return; - - Debug.Log($"[MusicCueLogger] Cue reached: {cueInfo.userCueName}"); - } - - private void OnDestroy() - { - if (_playingId != AkUnitySoundEngine.AK_INVALID_PLAYING_ID) - AkUnitySoundEngine.StopPlayingID(_playingId); - } -} diff --git a/Assets/_Content/Scripts/Core/Audio/MusicCueLogger.cs.meta b/Assets/_Content/Scripts/Core/Audio/MusicCueLogger.cs.meta deleted file mode 100644 index 312754eb..00000000 --- a/Assets/_Content/Scripts/Core/Audio/MusicCueLogger.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: a8c7b417b385a5b4babca499ff6b8a68 \ No newline at end of file diff --git a/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_DemoMusic.bnk b/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_DemoMusic.bnk index b615d0cb..f6e0e611 100644 --- a/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_DemoMusic.bnk +++ b/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_DemoMusic.bnk @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a5035d8866ce3e2a413abbdfb1f8e2a6a5f55b221500287cc6835f22978073f4 -size 6792 +oid sha256:439609f8e40926ec4e65b372352d9533eb41f3282cf42238ba7a89716412cc2a +size 6822 diff --git a/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_DemoMusic.json b/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_DemoMusic.json index 9ab1a2c1..3fdad5bc 100644 --- a/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_DemoMusic.json +++ b/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_DemoMusic.json @@ -10,7 +10,7 @@ "Type": "Event", "GUID": "{D20C85FC-37E9-4EE0-92B8-3248FD5060F9}", "Language": "SFX", - "Hash": "{C6F0FA51-F4FA-912C-4AC0-34070CB905AD}", + "Hash": "{99A33245-22FA-F3C5-A8ED-21AD03E8EC68}", "ObjectPath": "Play_DemoMusic", "ShortName": "Play_DemoMusic", "Path": "Event/Play_DemoMusic.bnk", @@ -416,6 +416,16 @@ } ] } + ], + "ActionSetState": [ + { + "GroupId": "3694735156", + "Id": "748895195", + "Name": "None", + "ObjectPath": "\\States\\Music\\Demo\\liminalSequence\\None", + "GUID": "{CA2310DD-7B55-4AE9-BB19-5EC534902613}", + "Color": "26" + } ] } ], @@ -513,6 +523,6 @@ ] } ], - "FileHash": "{F921E530-041B-772C-5352-9D9080C0400A}" + "FileHash": "{077F6F47-5E47-912E-9D04-A46588024E10}" } } \ No newline at end of file diff --git a/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_MarkerLane.bnk b/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_MarkerLane.bnk index c86429e6..af10ffe9 100644 --- a/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_MarkerLane.bnk +++ b/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_MarkerLane.bnk @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:41758fe9c1c5cfb012ebe86089a109e5b0d1fd697c636a1607528785feb5ed67 +oid sha256:f3480597ff3b02a7492c06ba56917b9187a40271f7f0cee8b0cdf679361f2d98 size 1373 diff --git a/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_MarkerLane.json b/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_MarkerLane.json index 63b6d0ba..a44861ba 100644 --- a/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_MarkerLane.json +++ b/RESIDENCY_POC_WwiseProject/GeneratedSoundBanks/Mac/Event/Play_MarkerLane.json @@ -10,7 +10,7 @@ "Type": "Event", "GUID": "{6ED4D87F-66B4-41C5-8EA7-585EB0A64E4B}", "Language": "SFX", - "Hash": "{FDEEC875-99D2-AEFC-D40A-7AD31FD1E150}", + "Hash": "{ECBAC43D-49B4-A5BD-D688-BCBBE654ABC4}", "ObjectPath": "Play_MarkerLane", "ShortName": "Play_MarkerLane", "Path": "Event/Play_MarkerLane.bnk", @@ -44,6 +44,6 @@ ] } ], - "FileHash": "{850829AF-A082-3695-BDB6-B4F0F43B1FC4}" + "FileHash": "{33FFF36D-8F80-01ED-02A5-6FB567EF4A0A}" } } \ No newline at end of file