wip : scene timing with music & early custom cue listener

This commit is contained in:
Hugo Le Bolloc'h
2026-05-22 00:21:12 +02:00
parent 891fe0c2ce
commit 109551017d
13 changed files with 299 additions and 136 deletions
+17 -17
View File
@@ -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}
+1 -1
View File
@@ -1199,7 +1199,7 @@ MonoBehaviour:
_tolerance: 0.5
_duration: 1
_execution: 1
_delay: 20
_delay: 14.9
_onTrigger:
m_PersistentCalls:
m_Calls: []
+1 -1
View File
@@ -681,7 +681,7 @@ MonoBehaviour:
_tolerance: 0.5
_duration: 1
_execution: 1
_delay: 20
_delay: 15
_onTrigger:
m_PersistentCalls:
m_Calls: []
@@ -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}
@@ -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}
@@ -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
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 57e4af8a70aa9904da2b35504ad63407
@@ -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);
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: a8c7b417b385a5b4babca499ff6b8a68