update debug tools

This commit is contained in:
Mikhail 2023-06-16 11:54:41 +08:00
parent b6db1dfe3f
commit 171bdb429c
5 changed files with 64 additions and 7 deletions

View File

@ -133,7 +133,8 @@ namespace DCFApixels.DragonECS
return; return;
string name = EcsEditor.GetGenericName(type); string name = EcsEditor.GetGenericName(type);
Color color = (GetAttribute<DebugColorAttribute>(type) ?? _fakeDebugColorAttribute).GetUnityColor(); //Color color = (GetAttribute<DebugColorAttribute>(type) ?? _fakeDebugColorAttribute).GetUnityColor();
Color color = EcsDebugUtility.GetColorRGB(type).ToUnityColor();
GUILayout.BeginVertical(EcsEditor.GetStyle(color, 0.2f)); GUILayout.BeginVertical(EcsEditor.GetStyle(color, 0.2f));
if (DebugMonitorPrefs.instance.IsShowInterfaces) if (DebugMonitorPrefs.instance.IsShowInterfaces)
@ -150,7 +151,9 @@ namespace DCFApixels.DragonECS
if (CheckIsHidden(type)) if (CheckIsHidden(type))
return; return;
Color color = (GetAttribute<DebugColorAttribute>(type) ?? _fakeDebugColorAttribute).GetUnityColor(); //Color color = (GetAttribute<DebugColorAttribute>(type) ?? _fakeDebugColorAttribute).GetUnityColor();
Color color = EcsDebugUtility.GetColorRGB(type).ToUnityColor();
GUILayout.BeginVertical(EcsEditor.GetStyle(color, 0.2f)); GUILayout.BeginVertical(EcsEditor.GetStyle(color, 0.2f));
GUILayout.Label(EcsEditor.GetGenericName(type), EditorStyles.boldLabel); GUILayout.Label(EcsEditor.GetGenericName(type), EditorStyles.boldLabel);
GUILayout.Label(string.Join(", ", runner.Targets.Cast<object>().Select(o => o.GetType().Name)), systemsListStyle); GUILayout.Label(string.Join(", ", runner.Targets.Cast<object>().Select(o => o.GetType().Name)), systemsListStyle);

View File

@ -169,7 +169,8 @@ namespace DCFApixels.DragonECS
Type type = browsable.GetType(); Type type = browsable.GetType();
string name = browsableName == null ? type.Name : GetLastPathComponent(browsableName.Name); string name = browsableName == null ? type.Name : GetLastPathComponent(browsableName.Name);
string description = customInitializer != null ? customInitializer.Description : initializerType.GetCustomAttribute<DebugDescriptionAttribute>()?.description; string description = customInitializer != null ? customInitializer.Description : initializerType.GetCustomAttribute<DebugDescriptionAttribute>()?.description;
Color panelColor = customInitializer != null ? customInitializer.Color : initializerType.GetCustomAttribute<DebugColorAttribute>()?.GetUnityColor() ?? Color.black; // Color panelColor = customInitializer != null ? customInitializer.Color : initializerType.GetCustomAttribute<DebugColorAttribute>()?.GetUnityColor() ?? Color.black;
Color panelColor = customInitializer != null ? customInitializer.Color : EcsDebugUtility.GetColorRGB(initializerType).ToUnityColor();
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();

View File

@ -38,9 +38,10 @@ namespace DCFApixels.DragonECS
#region Get meta #region Get meta
internal static Color GetColor(Type type) internal static Color GetColor(Type type)
{ {
var atr = type.GetCustomAttribute<DebugColorAttribute>(); //var atr = type.GetCustomAttribute<DebugColorAttribute>();
if (atr == null) return Color.black; //if (atr == null) return Color.black;
return atr.GetUnityColor(); //return atr.GetUnityColor();
return EcsDebugUtility.GetColorRGB(type).ToUnityColor();
} }
internal static string GetName(Type type) internal static string GetName(Type type)
{ {

View File

@ -2,6 +2,18 @@
namespace DCFApixels.DragonECS namespace DCFApixels.DragonECS
{ {
public interface IEcsGizmosProcess : IEcsProcess
{
public void DrawGizmos(EcsPipeline pipeline);
}
public static class IEcsGizmosProcessExtensions
{
public static void DrawGizmos(this EcsPipeline systems)
{
systems.GetRunner<IEcsGizmosProcess>().DrawGizmos(systems);
}
}
public interface IEcsLateRunProcess : IEcsProcess public interface IEcsLateRunProcess : IEcsProcess
{ {
public void LateRun(EcsPipeline pipeline); public void LateRun(EcsPipeline pipeline);
@ -27,6 +39,37 @@ namespace DCFApixels.DragonECS
namespace Internal namespace Internal
{ {
[DebugColor(DebugColor.Orange)]
public class EcsLateGizmosSystemRunner : EcsRunner<IEcsGizmosProcess>, IEcsGizmosProcess
{
#if DEBUG && !DISABLE_DEBUG
private EcsProfilerMarker[] _markers;
#endif
public void DrawGizmos(EcsPipeline pipeline)
{
#if DEBUG && !DISABLE_DEBUG
for (int i = 0; i < targets.Length; i++)
{
using (_markers[i].Auto())
targets[i].DrawGizmos(pipeline);
}
#else
foreach (var item in targets) item.DrawGizmos(pipeline);
#endif
}
#if DEBUG && !DISABLE_DEBUG
protected override void OnSetup()
{
_markers = new EcsProfilerMarker[targets.Length];
for (int i = 0; i < targets.Length; i++)
{
_markers[i] = new EcsProfilerMarker($"{targets[i].GetType().Name}.{nameof(DrawGizmos)}");
}
}
#endif
}
[DebugColor(DebugColor.Orange)] [DebugColor(DebugColor.Orange)]
public class EcsLateRunSystemRunner : EcsRunner<IEcsLateRunProcess>, IEcsLateRunProcess public class EcsLateRunSystemRunner : EcsRunner<IEcsLateRunProcess>, IEcsLateRunProcess
{ {

View File

@ -12,5 +12,14 @@ namespace DCFApixels.DragonECS
{ {
return new Color32(self.r, self.g, self.b, 255); return new Color32(self.r, self.g, self.b, 255);
} }
public static Color ToUnityColor(this (byte, byte, byte) self)
{
return new Color(self.Item1 / 255f, self.Item2 / 255f, self.Item3 / 255f);
}
public static Color32 ToUnityColor32(this (byte, byte, byte) self)
{
return new Color32(self.Item1, self.Item2, self.Item3, 255);
}
} }
} }