using AlicizaX.ObjectPool; using UnityEngine; using UnityEngine.UIElements; namespace AlicizaX.Debugger.Runtime { public sealed partial class DebuggerComponent { private sealed class ObjectPoolInformationWindow : PollingDebuggerWindowBase { private IObjectPoolService m_ObjectPoolService; public override void Initialize(params object[] args) { m_ObjectPoolService = AppServices.Require(); } protected override void BuildWindow(VisualElement root) { if (m_ObjectPoolService == null) { return; } VisualElement overview = CreateSection("Object Pool Overview", out VisualElement overviewCard); overviewCard.Add(CreateRow("Object Pool Count", m_ObjectPoolService.Count.ToString())); root.Add(overview); ObjectPoolBase[] objectPools = m_ObjectPoolService.GetAllObjectPools(true); for (int i = 0; i < objectPools.Length; i++) { ObjectPoolBase objectPool = objectPools[i]; VisualElement section = CreateSection(Utility.Text.Format("Object Pool: {0}", objectPool.FullName), out VisualElement card); card.Add(CreateRow("Name", objectPool.Name)); card.Add(CreateRow("Type", objectPool.ObjectType.FullName)); card.Add(CreateRow("Auto Release Interval", objectPool.AutoReleaseInterval.ToString())); card.Add(CreateRow("Capacity", objectPool.Capacity.ToString())); card.Add(CreateRow("Used Count", objectPool.Count.ToString())); card.Add(CreateRow("Can Release Count", objectPool.CanReleaseCount.ToString())); card.Add(CreateRow("Expire Time", objectPool.ExpireTime.ToString())); card.Add(CreateRow("Priority", objectPool.Priority.ToString())); ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos(); if (objectInfos.Length <= 0) { card.Add(CreateRow("Entries", "Object Pool is Empty ...")); } else { for (int j = 0; j < objectInfos.Length; j++) { ObjectInfo info = objectInfos[j]; string title = string.IsNullOrEmpty(info.Name) ? "" : info.Name; string content = Utility.Text.Format( "Locked {0} | {1} {2} | Flag {3} | Priority {4} | Last Use {5}", info.Locked, objectPool.AllowMultiSpawn ? "Count" : "InUse", objectPool.AllowMultiSpawn ? info.SpawnCount.ToString() : info.IsInUse.ToString(), info.CustomCanReleaseFlag, info.Priority, info.LastUseTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")); card.Add(CreateRow(title, content)); } } root.Add(section); } } } } }