using System; using System.Collections.Generic; using System.Text; using UnityEngine; using UnityEngine.UI; namespace OCES.Audio.Editor { #if UNITY_EDITOR public sealed class DebugInfoCollector : MonoBehaviour { public static DebugInfoCollector Instance { get; private set; } public Dictionary ClipConcurrentCount = new(); public List ActiveSounds = new(); public Dictionary ActiveStates = new(); readonly StringBuilder m_stringBuilder = new(); Text m_textComponent; void Awake() { if ((bool)Instance && Instance != this) { Destroy(gameObject); return; } Instance = this; this.m_textComponent = GetComponent(); } void Update() { this.m_stringBuilder.Clear(); this.m_stringBuilder.AppendLine("Current States:"); foreach (KeyValuePair activeState in this.ActiveStates) { string enumName = Enum.GetName(activeState.Key, activeState.Value) ?? activeState.Value.ToString(); this.m_stringBuilder.AppendLine($"{activeState.Key.Name} is {enumName}"); } this.m_stringBuilder.AppendLine(); this.m_stringBuilder.AppendLine("Clip Concurrent Count:"); foreach (KeyValuePair clipCount in this.ClipConcurrentCount) { this.m_stringBuilder.AppendLine($"{clipCount.Key} is playing {clipCount.Value}"); } this.m_stringBuilder.AppendLine(); this.m_stringBuilder.Append("ActiveSounds:"); foreach (ActiveSound activeSound in this.ActiveSounds) { this.m_stringBuilder.AppendLine($"{activeSound.AudioObject.Id}"); } this.m_textComponent.text = this.m_stringBuilder.ToString(); } } #endif }