com.alicizax.unity.framework/Runtime/Debugger/DebuggerComponent.ObjectPoolInformationWindow.cs

72 lines
3.3 KiB
C#
Raw Normal View History

using AlicizaX.ObjectPool;
2025-09-05 19:46:30 +08:00
using UnityEngine;
using UnityEngine.UIElements;
2025-09-05 19:46:30 +08:00
namespace AlicizaX.Debugger.Runtime
{
public sealed partial class DebuggerComponent
{
private sealed class ObjectPoolInformationWindow : PollingDebuggerWindowBase
2025-09-05 19:46:30 +08:00
{
private IObjectPoolService m_ObjectPoolService;
2025-09-05 19:46:30 +08:00
public override void Initialize(params object[] args)
{
m_ObjectPoolService = AppServices.Require<IObjectPoolService>();
2025-09-05 19:46:30 +08:00
}
protected override void BuildWindow(VisualElement root)
2025-09-05 19:46:30 +08:00
{
if (m_ObjectPoolService == null)
2025-09-05 19:46:30 +08:00
{
return;
2025-09-05 19:46:30 +08:00
}
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);
2025-09-05 19:46:30 +08:00
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()));
2025-09-05 19:46:30 +08:00
ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos();
if (objectInfos.Length <= 0)
2025-09-05 19:46:30 +08:00
{
card.Add(CreateRow("Entries", "Object Pool is Empty ..."));
2025-09-05 19:46:30 +08:00
}
else
2025-09-05 19:46:30 +08:00
{
for (int j = 0; j < objectInfos.Length; j++)
2025-09-05 19:46:30 +08:00
{
ObjectInfo info = objectInfos[j];
string title = string.IsNullOrEmpty(info.Name) ? "<None>" : 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));
2025-09-05 19:46:30 +08:00
}
}
root.Add(section);
2025-09-05 19:46:30 +08:00
}
}
}
}
}