53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using UnityEngine;
|
|
using Unheimlich.Gameplay.Portals;
|
|
|
|
namespace Unheimlich.Audio
|
|
{
|
|
public class PortalAudioDebugger : MonoBehaviour
|
|
{
|
|
private Portal _portal;
|
|
|
|
private void Awake()
|
|
{
|
|
_portal = GetComponent<Portal>();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (_portal != null)
|
|
{
|
|
_portal.RoomLoaded += OnRoomLoadedDebug;
|
|
_portal.RoomUnloaded += OnRoomUnloadedDebug;
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
if (_portal != null)
|
|
{
|
|
_portal.RoomLoaded -= OnRoomLoadedDebug;
|
|
_portal.RoomUnloaded -= OnRoomUnloadedDebug;
|
|
}
|
|
}
|
|
|
|
private void OnRoomLoadedDebug()
|
|
{
|
|
Debug.Log($"<color=green>[PortalDebug] RoomLoaded event fired on {gameObject.name}</color>");
|
|
|
|
if (_portal.LoadedRoomInstance != null)
|
|
{
|
|
AudioSource[] sources = _portal.LoadedRoomInstance.GetComponentsInChildren<AudioSource>();
|
|
Debug.Log($"<color=green>[PortalDebug] Found {sources.Length} AudioSources in loaded room:</color>");
|
|
|
|
foreach (var source in sources)
|
|
Debug.Log($" - {source.name} | Playing: {source.isPlaying} | Clip: {(source.clip != null ? source.clip.name : "NULL")}");
|
|
}
|
|
}
|
|
|
|
private void OnRoomUnloadedDebug()
|
|
{
|
|
Debug.Log($"<color=red>[PortalDebug] RoomUnloaded event fired on {gameObject.name}</color>");
|
|
}
|
|
}
|
|
}
|