private void DrawObjectPool(ObjectPoolBase objectPool) { GUILayout.Label(Utility.Text.Format("<b>Object Pool: {0}</b>", 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("<b>Name</b>"); GUILayout.Label("<b>Locked</b>", GUILayout.Width(60f)); GUILayout.Label(objectPool.AllowMultiSpawn ? "<b>Count</b>" : "<b>In Use</b>", GUILayout.Width(60f)); GUILayout.Label("<b>Flag</b>", GUILayout.Width(60f)); GUILayout.Label("<b>Priority</b>", GUILayout.Width(60f)); GUILayout.Label("<b>Last Use Time</b>", 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) ? "<None>" : 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.ToString("yyyy-MM-dd HH:mm:ss"), GUILayout.Width(120f)); } GUILayout.EndHorizontal(); } } else { GUILayout.Label("<i>Object Pool is Empty ...</i>"); } } GUILayout.EndVertical(); }
private void DrawObjectPool(ObjectPoolBase objectPool) { bool lastState = m_OpenedItems.Contains(objectPool.FullName); bool currentState = EditorGUILayout.Foldout(lastState, objectPool.FullName); if (currentState != lastState) { if (currentState) { m_OpenedItems.Add(objectPool.FullName); } else { m_OpenedItems.Remove(objectPool.FullName); } } if (currentState) { EditorGUILayout.BeginVertical("box"); { EditorGUILayout.LabelField("Name", objectPool.Name); EditorGUILayout.LabelField("Type", objectPool.ObjectType.FullName); EditorGUILayout.LabelField("Auto Release Interval", objectPool.AutoReleaseInterval.ToString()); EditorGUILayout.LabelField("Capacity", objectPool.Capacity.ToString()); EditorGUILayout.LabelField("Used Count", objectPool.Count.ToString()); EditorGUILayout.LabelField("Can Release Count", objectPool.CanReleaseCount.ToString()); EditorGUILayout.LabelField("Expire Time", objectPool.ExpireTime.ToString()); EditorGUILayout.LabelField("Priority", objectPool.Priority.ToString()); ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos(); if (objectInfos.Length > 0) { foreach (ObjectInfo objectInfo in objectInfos) { EditorGUILayout.LabelField(objectInfo.Name, Utility.Text.Format("{0}, {1}, {2}, {3}, {4}", objectInfo.Locked.ToString(), objectPool.AllowMultiSpawn ? objectInfo.SpawnCount.ToString() : objectInfo.IsInUse.ToString(), objectInfo.CustomCanReleaseFlag.ToString(), objectInfo.Priority.ToString(), objectInfo.LastUseTime.ToString("yyyy-MM-dd HH:mm:ss"))); } } else { GUILayout.Label("Object Pool is Empty ..."); } } EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); } }
private void DrawObjectPool(ObjectPoolBase objectPool) { GUILayout.Label(string.Format("<b>Object Pool: {0}</b>", string.IsNullOrEmpty(objectPool.Name) ? "<Unnamed>" : objectPool.Name)); GUILayout.BeginVertical("box"); { DrawItem("Type", objectPool.ObjectType.FullName); DrawItem("Auto Release Interval", objectPool.AutoReleaseInterval.ToString()); DrawItem("Capacity", string.Format("{0} / {1} / {2}", objectPool.CanReleaseCount.ToString(), objectPool.Count.ToString(), objectPool.Capacity.ToString())); DrawItem("Expire Time", objectPool.ExpireTime.ToString()); DrawItem("Priority", objectPool.Priority.ToString()); ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos(); GUILayout.BeginHorizontal(); { GUILayout.Label("<b>Name</b>"); GUILayout.Label("<b>Locked</b>", GUILayout.Width(60f)); GUILayout.Label(objectPool.AllowMultiSpawn ? "<b>Count</b>" : "<b>In Use</b>", GUILayout.Width(60f)); GUILayout.Label("<b>Priority</b>", GUILayout.Width(60f)); GUILayout.Label("<b>Last Use Time</b>", GUILayout.Width(120f)); } GUILayout.EndHorizontal(); if (objectInfos.Length > 0) { foreach (ObjectInfo objectInfo in objectInfos) { GUILayout.BeginHorizontal(); { GUILayout.Label(objectInfo.Name); GUILayout.Label(objectInfo.Locked.ToString(), GUILayout.Width(60f)); GUILayout.Label(objectPool.AllowMultiSpawn ? objectInfo.SpawnCount.ToString() : objectInfo.IsInUse.ToString(), GUILayout.Width(60f)); GUILayout.Label(objectInfo.Priority.ToString(), GUILayout.Width(60f)); GUILayout.Label(objectInfo.LastUseTime.ToString("yyyy-MM-dd HH:mm:ss"), GUILayout.Width(120f)); } GUILayout.EndHorizontal(); } } else { GUILayout.Label("<i>Object Pool is Empty ...</i>"); } } GUILayout.EndVertical(); }
private void DrawObjectPool(ObjectPoolBase objectPool) { GUILayout.Label(string.Format("<b>Object Pool: {0}</b>", string.IsNullOrEmpty(objectPool.Name) ? "<Unnamed>" : objectPool.Name)); GUILayout.BeginVertical("box"); { DrawItem("Type", objectPool.ObjectType.FullName); DrawItem("Capacity", string.Format("{0} / {1}", objectPool.Count.ToString(), objectPool.Capacity.ToString())); ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos(); if (objectInfos.Length > 0) { GUILayout.BeginHorizontal(); { GUILayout.Label("<b>Name</b>"); GUILayout.Label("<b>Locked</b>", GUILayout.Width(60f)); GUILayout.Label("<b>Count</b>", GUILayout.Width(60f)); GUILayout.Label("<b>Priority</b>", GUILayout.Width(60f)); GUILayout.Label("<b>Last Use Time</b>", GUILayout.Width(120f)); } GUILayout.EndHorizontal(); } foreach (ObjectInfo objectInfo in objectInfos) { GUILayout.BeginHorizontal(); { GUILayout.Label(objectInfo.Name); GUILayout.Label(objectInfo.Locked.ToString(), GUILayout.Width(60f)); GUILayout.Label(objectInfo.SpawnCount.ToString(), GUILayout.Width(60f)); GUILayout.Label(objectInfo.Priority.ToString(), GUILayout.Width(60f)); GUILayout.Label(objectInfo.LastUseTime.ToString("yyyy-MM-dd HH:mm:ss"), GUILayout.Width(120f)); } GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); }
private void DrawObjectPool(ObjectPoolBase objectPool) { bool lastState = m_OpenedItems.Contains(objectPool.FullName); bool currentState = EditorGUILayout.Foldout(lastState, objectPool.FullName); if (currentState != lastState) { if (currentState) { m_OpenedItems.Add(objectPool.FullName); } else { m_OpenedItems.Remove(objectPool.FullName); } } if (currentState) { EditorGUILayout.BeginVertical("box"); { EditorGUILayout.LabelField("Name", objectPool.Name); EditorGUILayout.LabelField("Type", objectPool.ObjectType.FullName); EditorGUILayout.LabelField("Auto Release Interval", objectPool.AutoReleaseInterval.ToString()); EditorGUILayout.LabelField("Capacity", objectPool.Capacity.ToString()); EditorGUILayout.LabelField("Used Count", objectPool.Count.ToString()); EditorGUILayout.LabelField("Can Release Count", objectPool.CanReleaseCount.ToString()); EditorGUILayout.LabelField("Expire Time", objectPool.ExpireTime.ToString()); EditorGUILayout.LabelField("Priority", objectPool.Priority.ToString()); ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos(); if (objectInfos.Length > 0) { foreach (ObjectInfo objectInfo in objectInfos) { EditorGUILayout.LabelField(objectInfo.Name, Utility.Text.Format("{0}, {1}, {2}, {3}, {4}", objectInfo.Locked.ToString(), objectPool.AllowMultiSpawn ? objectInfo.SpawnCount.ToString() : objectInfo.IsInUse.ToString(), objectInfo.CustomCanReleaseFlag.ToString(), objectInfo.Priority.ToString(), objectInfo.LastUseTime.ToString("yyyy-MM-dd HH:mm:ss"))); } if (GUILayout.Button("Release")) { objectPool.Release(); } if (GUILayout.Button("Release All Unused")) { objectPool.ReleaseAllUnused(); } if (GUILayout.Button("Export CSV Data")) { string exportFileName = EditorUtility.SaveFilePanel("Export CSV Data", string.Empty, Utility.Text.Format("Object Pool Data - {0}.csv", objectPool.Name), string.Empty); if (!string.IsNullOrEmpty(exportFileName)) { try { int index = 0; string[] data = new string[objectInfos.Length + 1]; data[index++] = Utility.Text.Format("Name,Locked,{0},Custom Can Release Flag,Priority,Last Use Time", objectPool.AllowMultiSpawn ? "Count" : "In Use"); foreach (ObjectInfo objectInfo in objectInfos) { data[index++] = Utility.Text.Format("{0},{1},{2},{3},{4},{5}", objectInfo.Name, objectInfo.Locked.ToString(), objectPool.AllowMultiSpawn ? objectInfo.SpawnCount.ToString() : objectInfo.IsInUse.ToString(), objectInfo.CustomCanReleaseFlag.ToString(), objectInfo.Priority.ToString(), objectInfo.LastUseTime.ToString("yyyy-MM-dd HH:mm:ss")); } File.WriteAllLines(exportFileName, data, Encoding.UTF8); Debug.Log(Utility.Text.Format("Export object pool CSV data to '{0}' success.", exportFileName)); } catch (Exception exception) { Debug.LogError(Utility.Text.Format("Export object pool CSV data to '{0}' failure, exception is '{1}'.", exportFileName, exception.ToString())); } } } } else { GUILayout.Label("Object Pool is Empty ..."); } } EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); } }
//绘制对象池信息 private void DrawObjectPool(ObjectPoolBase objectPool) { bool lastState = m_OpenedItems.Contains(objectPool.FullName); //上次状态 bool currentState = EditorGUILayout.Foldout(lastState, objectPool.FullName); //文件夹状态 if (currentState != lastState) { if (currentState) { m_OpenedItems.Add(objectPool.FullName); } else { m_OpenedItems.Remove(objectPool.FullName); } } //打开状态下,显示对对象池相关信息 if (currentState) { EditorGUILayout.BeginVertical("box"); { EditorGUILayout.LabelField("Name", objectPool.Name); //对象池名称 EditorGUILayout.LabelField("Type", objectPool.ObjectType.FullName); //对象池类型 EditorGUILayout.LabelField("Auto Release Interval", objectPool.AutoReleaseInterval.ToString()); //自动释放频率 EditorGUILayout.LabelField("Capacity", objectPool.Capacity.ToString()); //对象池容量 EditorGUILayout.LabelField("Used Count", objectPool.Count.ToString()); //使用的对象数量 EditorGUILayout.LabelField("Can Release Count", objectPool.CanReleaseCount.ToString()); //可释放的数量 EditorGUILayout.LabelField("Expire Time", objectPool.ExpireTime.ToString()); //过期秒数 EditorGUILayout.LabelField("Priority", objectPool.Priority.ToString()); //优先级 ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos(); if (objectInfos.Length > 0) { for (int i = 0; i < objectInfos.Length; i++) { var objectInfo = objectInfos[i]; //对象信息 EditorGUILayout.LabelField(objectInfo.Name, Utility.Text.Format("{0}, {1}, {2}, {3}", objectInfo.Locked.ToString(), objectPool.AllowMultiSpawn ? objectInfo.SpawnCount.ToString() : objectInfo.IsInUse.ToString(), objectInfo.Priority.ToString(), objectInfo.LastUseTime.ToString("yyyy-MM-dd HH:mm:ss"))); } if (GUILayout.Button("Release")) //释放对象池 { objectPool.Release(); } if (GUILayout.Button("Release All Unused")) //释放所有未使用的对象 { objectPool.ReleaseAllUnused(); } if (GUILayout.Button("Export SCV Data")) //导出CSV数据 { string exportFileName = EditorUtility.SaveFilePanel("Export CSV Data", string.Empty, Utility.Text.Format("Object Pool Data - {0}.csv", objectPool.Name), string.Empty); try { int index = 0; string[] data = new string[objectInfos.Length + 1]; data[index++] = Utility.Text.Format("Name,Locked,{0},Custom Can Release Flag,Priority,Last Use Time", objectPool.AllowMultiSpawn ? "Count" : "IsUsing"); for (int i = 0; i < objectInfos.Length; i++) { ObjectInfo objectInfo = objectInfos[i]; data[index++] = Utility.Text.Format("{0},{1},{2},{3},{4},{5}", objectInfo.Name, objectInfo.Locked.ToString(), objectPool.AllowMultiSpawn ? objectInfo.SpawnCount.ToString() : objectInfo.IsInUse.ToString(), objectInfo.CustomCanReleaseFlag.ToString(), objectInfo.Priority.ToString(), objectInfo.LastUseTime.ToString("yyyy-MM-dd HH:mm:ss")); } File.WriteAllLines(exportFileName, data, Encoding.UTF8); Debug.Log(Utility.Text.Format("Export CSV data to '{0}' success.", exportFileName)); } catch (Exception exception) { Debug.LogError(Utility.Text.Format("Export CSV data to '{0}' failure, exception is '{1}'.", exportFileName, exception.Message)); } } } else { GUILayout.Label("Object Pool is Empty ..."); } } EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); } }