Files
Ipseity-Demo/Assets/Unheimlich_POC/Scripts/Dev/DebugTools/PortalAudioDebugger.cs
T

55 lines
1.5 KiB
C#

#if UNITY_EDITOR || DEVELOPMENT_BUILD
using UnityEngine;
using Unheimlich.Features.Portals;
namespace Unheimlich.Dev
{
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>");
}
}
}
#endif