Merge branch 'main' of http://212.24.110.183:3000/IPSEITY/Unheimlich_POC
# Conflicts: # Assets/_Content/Scenes/BodiesInWater.unity
This commit is contained in:
@@ -49,7 +49,7 @@ public class Audio_AudioManager : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("AudioManager already exist! Destroying new ibnstance.");
|
||||
Debug.LogWarning("AudioManager already exist! Destroying new instance.");
|
||||
Destroy(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Audio_PersistentManager : MonoBehaviour
|
||||
{
|
||||
public static Audio_PersistentManager Instance { get; private set; }
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// If an instance already exists and it's not this one, destroy this duplicate
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 020f1ac3c4ebf6e49b89ba31175bb728
|
||||
@@ -0,0 +1,62 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class Audio_WwiseEventTrigger : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public class WwiseEventEntry
|
||||
{
|
||||
public string label = "Event";
|
||||
public AK.Wwise.Event wwiseEvent;
|
||||
public bool triggerOnEnter = true;
|
||||
public bool triggerOnExit = false;
|
||||
}
|
||||
|
||||
[Header("Wwise Events")]
|
||||
[SerializeField] private List<WwiseEventEntry> wwiseEvents = new List<WwiseEventEntry>();
|
||||
|
||||
[Header("Trigger Settings")]
|
||||
[SerializeField] private string playerTag = "Player";
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GetComponent<Collider>().isTrigger = true;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (!other.CompareTag(playerTag)) return;
|
||||
|
||||
foreach (var entry in wwiseEvents)
|
||||
{
|
||||
if (entry.triggerOnEnter && entry.wwiseEvent != null)
|
||||
entry.wwiseEvent.Post(other.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (!other.CompareTag(playerTag)) return;
|
||||
|
||||
foreach (var entry in wwiseEvents)
|
||||
{
|
||||
if (entry.triggerOnExit && entry.wwiseEvent != null)
|
||||
entry.wwiseEvent.Post(other.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
BoxCollider box = GetComponent<BoxCollider>();
|
||||
if (box == null) return;
|
||||
|
||||
Gizmos.matrix = transform.localToWorldMatrix;
|
||||
Gizmos.color = new Color(1f, 0.5f, 0f, 0.25f);
|
||||
Gizmos.DrawCube(box.center, box.size);
|
||||
Gizmos.color = new Color(1f, 0.5f, 0f, 0.8f);
|
||||
Gizmos.DrawWireCube(box.center, box.size);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c1cc6d5ab210fa4baa79dabb29253e3
|
||||
Reference in New Issue
Block a user