//------------------------------------------------------------ // Game Framework // Copyright © 2013-2021 loyalsoft. All rights reserved. // Homepage: http://www.game7000.com/ // Feedback: http://www.game7000.com/ //------------------------------------------------------------ using GameFramework; using GameFramework.ObjectPool; using UnityEngine; namespace UnityGameFramework.Runtime { public sealed partial class DebuggerComponent : GameFrameworkComponent { private sealed class ObjectPoolInformationWindow : ScrollableDebuggerWindowBase { private ObjectPoolComponent m_ObjectPoolComponent = null; public override void Initialize(params object[] args) { m_ObjectPoolComponent = GameEntry.GetComponent(); if (m_ObjectPoolComponent == null) { Log.Fatal("Object pool component is invalid."); return; } } protected override void OnDrawScrollableWindow() { GUILayout.Label("Object Pool Information"); GUILayout.BeginVertical("box"); { DrawItem("Object Pool Count", m_ObjectPoolComponent.Count.ToString()); } GUILayout.EndVertical(); ObjectPoolBase[] objectPools = m_ObjectPoolComponent.GetAllObjectPools(true); for (int i = 0; i < objectPools.Length; i++) { DrawObjectPool(objectPools[i]); } } private void DrawObjectPool(ObjectPoolBase objectPool) { GUILayout.Label(Utility.Text.Format("Object Pool: {0}", objectPool.FullName)); GUILayout.BeginVertical("box"); { DrawItem("Name", objectPool.Name); DrawItem("Type", objectPool.ObjectType.FullName); DrawItem("Auto Release Interval", objectPool.AutoReleaseInterval.ToString()); DrawItem("Capacity", objectPool.Capacity.ToString()); DrawItem("Used Count", objectPool.Count.ToString()); DrawItem("Can Release Count", objectPool.CanReleaseCount.ToString()); DrawItem("Expire Time", objectPool.ExpireTime.ToString()); DrawItem("Priority", objectPool.Priority.ToString()); ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos(); GUILayout.BeginHorizontal(); { GUILayout.Label("Name"); GUILayout.Label("Locked", GUILayout.Width(60f)); GUILayout.Label(objectPool.AllowMultiSpawn ? "Count" : "In Use", GUILayout.Width(60f)); GUILayout.Label("Flag", GUILayout.Width(60f)); GUILayout.Label("Priority", GUILayout.Width(60f)); GUILayout.Label("Last Use Time", GUILayout.Width(120f)); } GUILayout.EndHorizontal(); if (objectInfos.Length > 0) { for (int i = 0; i < objectInfos.Length; i++) { GUILayout.BeginHorizontal(); { GUILayout.Label(string.IsNullOrEmpty(objectInfos[i].Name) ? "" : objectInfos[i].Name); GUILayout.Label(objectInfos[i].Locked.ToString(), GUILayout.Width(60f)); GUILayout.Label(objectPool.AllowMultiSpawn ? objectInfos[i].SpawnCount.ToString() : objectInfos[i].IsInUse.ToString(), GUILayout.Width(60f)); GUILayout.Label(objectInfos[i].CustomCanReleaseFlag.ToString(), GUILayout.Width(60f)); GUILayout.Label(objectInfos[i].Priority.ToString(), GUILayout.Width(60f)); GUILayout.Label(objectInfos[i].LastUseTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), GUILayout.Width(120f)); } GUILayout.EndHorizontal(); } } else { GUILayout.Label("Object Pool is Empty ..."); } } GUILayout.EndVertical(); } } } }