DebuggerComponent.ObjectPoolInformationWindow.cs 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using GameFramework;
  8. using GameFramework.ObjectPool;
  9. using UnityEngine;
  10. namespace UnityGameFramework.Runtime
  11. {
  12. public sealed partial class DebuggerComponent : GameFrameworkComponent
  13. {
  14. private sealed class ObjectPoolInformationWindow : ScrollableDebuggerWindowBase
  15. {
  16. private ObjectPoolComponent m_ObjectPoolComponent = null;
  17. public override void Initialize(params object[] args)
  18. {
  19. m_ObjectPoolComponent = GameEntry.GetComponent<ObjectPoolComponent>();
  20. if (m_ObjectPoolComponent == null)
  21. {
  22. Log.Fatal("Object pool component is invalid.");
  23. return;
  24. }
  25. }
  26. protected override void OnDrawScrollableWindow()
  27. {
  28. GUILayout.Label("<b>Object Pool Information</b>");
  29. GUILayout.BeginVertical("box");
  30. {
  31. DrawItem("Object Pool Count", m_ObjectPoolComponent.Count.ToString());
  32. }
  33. GUILayout.EndVertical();
  34. ObjectPoolBase[] objectPools = m_ObjectPoolComponent.GetAllObjectPools(true);
  35. for (int i = 0; i < objectPools.Length; i++)
  36. {
  37. DrawObjectPool(objectPools[i]);
  38. }
  39. }
  40. private void DrawObjectPool(ObjectPoolBase objectPool)
  41. {
  42. GUILayout.Label(Utility.Text.Format("<b>Object Pool: {0}</b>", objectPool.FullName));
  43. GUILayout.BeginVertical("box");
  44. {
  45. DrawItem("Name", objectPool.Name);
  46. DrawItem("Type", objectPool.ObjectType.FullName);
  47. DrawItem("Auto Release Interval", objectPool.AutoReleaseInterval.ToString());
  48. DrawItem("Capacity", objectPool.Capacity.ToString());
  49. DrawItem("Used Count", objectPool.Count.ToString());
  50. DrawItem("Can Release Count", objectPool.CanReleaseCount.ToString());
  51. DrawItem("Expire Time", objectPool.ExpireTime.ToString());
  52. DrawItem("Priority", objectPool.Priority.ToString());
  53. ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos();
  54. GUILayout.BeginHorizontal();
  55. {
  56. GUILayout.Label("<b>Name</b>");
  57. GUILayout.Label("<b>Locked</b>", GUILayout.Width(60f));
  58. GUILayout.Label(objectPool.AllowMultiSpawn ? "<b>Count</b>" : "<b>In Use</b>", GUILayout.Width(60f));
  59. GUILayout.Label("<b>Flag</b>", GUILayout.Width(60f));
  60. GUILayout.Label("<b>Priority</b>", GUILayout.Width(60f));
  61. GUILayout.Label("<b>Last Use Time</b>", GUILayout.Width(120f));
  62. }
  63. GUILayout.EndHorizontal();
  64. if (objectInfos.Length > 0)
  65. {
  66. for (int i = 0; i < objectInfos.Length; i++)
  67. {
  68. GUILayout.BeginHorizontal();
  69. {
  70. GUILayout.Label(string.IsNullOrEmpty(objectInfos[i].Name) ? "<None>" : objectInfos[i].Name);
  71. GUILayout.Label(objectInfos[i].Locked.ToString(), GUILayout.Width(60f));
  72. GUILayout.Label(objectPool.AllowMultiSpawn ? objectInfos[i].SpawnCount.ToString() : objectInfos[i].IsInUse.ToString(), GUILayout.Width(60f));
  73. GUILayout.Label(objectInfos[i].CustomCanReleaseFlag.ToString(), GUILayout.Width(60f));
  74. GUILayout.Label(objectInfos[i].Priority.ToString(), GUILayout.Width(60f));
  75. GUILayout.Label(objectInfos[i].LastUseTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), GUILayout.Width(120f));
  76. }
  77. GUILayout.EndHorizontal();
  78. }
  79. }
  80. else
  81. {
  82. GUILayout.Label("<i>Object Pool is Empty ...</i>");
  83. }
  84. }
  85. GUILayout.EndVertical();
  86. }
  87. }
  88. }
  89. }