mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
update debug utils
This commit is contained in:
parent
e7c3fb77fc
commit
9a78a38c72
94
src/DebugUtils/Monitors/Editor/WorldQueriesMonitorEditor.cs
Normal file
94
src/DebugUtils/Monitors/Editor/WorldQueriesMonitorEditor.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
#if UNITY_EDITOR
|
||||||
|
using DCFApixels.DragonECS.Core;
|
||||||
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
|
{
|
||||||
|
[CustomEditor(typeof(WorldQueriesMonitor))]
|
||||||
|
internal class WorldQueriesMonitorEditor : ExtendedEditor<WorldQueriesMonitor>
|
||||||
|
{
|
||||||
|
protected override void DrawCustom()
|
||||||
|
{
|
||||||
|
var executors = Target.MaskQueryExecutors;
|
||||||
|
|
||||||
|
EditorGUILayout.IntField("Count: ", executors.Count);
|
||||||
|
GUILayout.Space(20);
|
||||||
|
|
||||||
|
//using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f)))
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
foreach (var executor in executors)
|
||||||
|
{
|
||||||
|
DrawQueryInfo(executor, i++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static Color GetGenericPanelColor(int index)
|
||||||
|
{
|
||||||
|
return (index & 1) == 0 ? new Color(0, 0, 0, 0) : new Color(0.4f, 0.4f, 0.4f, 0.2f);
|
||||||
|
}
|
||||||
|
private void DrawQueryInfo(MaskQueryExecutor executor, int index)
|
||||||
|
{
|
||||||
|
//GUILayout.Space(10f);
|
||||||
|
|
||||||
|
//using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(GetGenericPanelColor(index))))
|
||||||
|
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f)))
|
||||||
|
{
|
||||||
|
var mask = executor.Mask;
|
||||||
|
DrawConstraint("+", mask.Incs);
|
||||||
|
DrawConstraint("-", mask.Excs);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.LongField("Version: ", executor.Version);
|
||||||
|
EditorGUILayout.IntField("Entites Count: ", executor.LastCachedCount);
|
||||||
|
|
||||||
|
//var rect = GUILayoutUtility.GetLastRect();
|
||||||
|
//
|
||||||
|
//rect.xMax = rect.xMin;
|
||||||
|
//rect.xMin -= 2f;
|
||||||
|
//
|
||||||
|
//EditorGUI.DrawRect(rect, new Color(0, 0, 0, 0.8f));
|
||||||
|
}
|
||||||
|
private void DrawConstraint(string title, ReadOnlySpan<int> ids)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (ids.Length <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (EcsGUI.Layout.BeginHorizontal())
|
||||||
|
{
|
||||||
|
using (EcsGUI.SetAlignment(value: TextAnchor.MiddleCenter))
|
||||||
|
using (EcsGUI.SetFontStyle(value: FontStyle.Bold))
|
||||||
|
using (EcsGUI.SetFontSize(value: 18))
|
||||||
|
using (EcsGUI.SetColor(Color.white, 0.3f))
|
||||||
|
GUILayout.Label(title, GUILayout.Width(12));
|
||||||
|
|
||||||
|
using (EcsGUI.Layout.BeginVertical())
|
||||||
|
{
|
||||||
|
foreach (var inc in ids)
|
||||||
|
{
|
||||||
|
Type type = Target.World.GetComponentType(inc);
|
||||||
|
TypeMeta meta = type.ToMeta();
|
||||||
|
|
||||||
|
Color color = EcsGUI.SelectPanelColor(meta, i, 9);
|
||||||
|
|
||||||
|
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(color, 0.2f)))
|
||||||
|
{
|
||||||
|
GUILayout.Label(meta.TypeName);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.Space(6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1014ae1a0eb53564da3d64f37ca26b6e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -31,6 +31,7 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
|||||||
{
|
{
|
||||||
private EcsWorld _world;
|
private EcsWorld _world;
|
||||||
private WorldMonitor _monitor;
|
private WorldMonitor _monitor;
|
||||||
|
private WorldQueriesMonitor _queriesMonitor;
|
||||||
private Transform _entityMonitorsPoolRoot;
|
private Transform _entityMonitorsPoolRoot;
|
||||||
private EntityMonitor[] _entityMonitors;
|
private EntityMonitor[] _entityMonitors;
|
||||||
public EcsWorld World
|
public EcsWorld World
|
||||||
@ -54,7 +55,9 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
|||||||
TypeMeta meta = _world.GetMeta();
|
TypeMeta meta = _world.GetMeta();
|
||||||
_monitor = new GameObject($"{UnityEditorUtility.TransformToUpperName(meta.Name)} ( {_world.ID} )").AddComponent<WorldMonitor>();
|
_monitor = new GameObject($"{UnityEditorUtility.TransformToUpperName(meta.Name)} ( {_world.ID} )").AddComponent<WorldMonitor>();
|
||||||
UnityEngine.Object.DontDestroyOnLoad(_monitor);
|
UnityEngine.Object.DontDestroyOnLoad(_monitor);
|
||||||
|
_queriesMonitor = _monitor.gameObject.AddComponent<WorldQueriesMonitor>();
|
||||||
_monitor.Set(_world);
|
_monitor.Set(_world);
|
||||||
|
_queriesMonitor.Set(_world);
|
||||||
_monitor.gameObject.SetActive(false);
|
_monitor.gameObject.SetActive(false);
|
||||||
|
|
||||||
_entityMonitorsPoolRoot = new GameObject("__pool__").transform;
|
_entityMonitorsPoolRoot = new GameObject("__pool__").transform;
|
||||||
|
35
src/DebugUtils/Monitors/WorldQueriesMonitor.cs
Normal file
35
src/DebugUtils/Monitors/WorldQueriesMonitor.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using DCFApixels.DragonECS.Core;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS.Unity.Internal
|
||||||
|
{
|
||||||
|
[MetaColor(MetaColor.Gray)]
|
||||||
|
[MetaGroup(EcsUnityConsts.PACK_GROUP, EcsConsts.DEBUG_GROUP)]
|
||||||
|
[MetaDescription(EcsConsts.AUTHOR, "...")]
|
||||||
|
[MetaTags(MetaTags.HIDDEN)]
|
||||||
|
[MetaID("AC178504930164FD2EABFA071EF0476F")]
|
||||||
|
internal class WorldQueriesMonitor : MonoBehaviour
|
||||||
|
{
|
||||||
|
private EcsWorld _world;
|
||||||
|
private List<MaskQueryExecutor> _maskQueryExecutors = new List<MaskQueryExecutor>();
|
||||||
|
private int _maskQueryExecutorsVersion = 0;
|
||||||
|
|
||||||
|
public EcsWorld World
|
||||||
|
{
|
||||||
|
get { return _world; }
|
||||||
|
}
|
||||||
|
public List<MaskQueryExecutor> MaskQueryExecutors
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
_world.GetMaskQueryExecutors(_maskQueryExecutors, ref _maskQueryExecutorsVersion);
|
||||||
|
return _maskQueryExecutors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Set(EcsWorld world)
|
||||||
|
{
|
||||||
|
_world = world;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
src/DebugUtils/Monitors/WorldQueriesMonitor.cs.meta
Normal file
11
src/DebugUtils/Monitors/WorldQueriesMonitor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: af5898847627f4241bbb9cf970e90d31
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -715,10 +715,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
Color hsv = Color.HSVToRGB(1f / localTotal * (index % localTotal), 1, 1);
|
Color hsv = Color.HSVToRGB(1f / localTotal * (index % localTotal), 1, 1);
|
||||||
return hsv.Desaturate(0.48f) / 1.18f;
|
return hsv.Desaturate(0.48f) / 1.18f;
|
||||||
default:
|
default:
|
||||||
|
return GetGenericPanelColor(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static Color GetGenericPanelColor(int index)
|
||||||
|
{
|
||||||
return index % 2 == 0 ? new Color(0.40f, 0.40f, 0.40f) : new Color(0.54f, 0.54f, 0.54f);
|
return index % 2 == 0 ? new Color(0.40f, 0.40f, 0.40f) : new Color(0.54f, 0.54f, 0.54f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Other Elements
|
#region Other Elements
|
||||||
@ -1083,6 +1087,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
int leakedEntitesCount = isNull ? 0 : world.CountLeakedEntitesDebug();
|
int leakedEntitesCount = isNull ? 0 : world.CountLeakedEntitesDebug();
|
||||||
EditorGUILayout.IntField("Entities", entitesCount, EditorStyles.boldLabel);
|
EditorGUILayout.IntField("Entities", entitesCount, EditorStyles.boldLabel);
|
||||||
EditorGUILayout.IntField("Capacity", capacity, EditorStyles.boldLabel);
|
EditorGUILayout.IntField("Capacity", capacity, EditorStyles.boldLabel);
|
||||||
|
EditorGUILayout.LongField("Version", world.Version, EditorStyles.boldLabel);
|
||||||
Color color = leakedEntitesCount > 0 ? Color.yellow : GUI.contentColor;
|
Color color = leakedEntitesCount > 0 ? Color.yellow : GUI.contentColor;
|
||||||
using (new ContentColorScope(color))
|
using (new ContentColorScope(color))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user