diff --git a/src/Debug/Systems/PipelineDebugSystem.cs b/src/Debug/Systems/PipelineDebugSystem.cs index dc609ef..273a103 100644 --- a/src/Debug/Systems/PipelineDebugSystem.cs +++ b/src/Debug/Systems/PipelineDebugSystem.cs @@ -133,7 +133,8 @@ namespace DCFApixels.DragonECS return; string name = EcsEditor.GetGenericName(type); - Color color = (GetAttribute(type) ?? _fakeDebugColorAttribute).GetUnityColor(); + //Color color = (GetAttribute(type) ?? _fakeDebugColorAttribute).GetUnityColor(); + Color color = EcsDebugUtility.GetColorRGB(type).ToUnityColor(); GUILayout.BeginVertical(EcsEditor.GetStyle(color, 0.2f)); if (DebugMonitorPrefs.instance.IsShowInterfaces) @@ -150,7 +151,9 @@ namespace DCFApixels.DragonECS if (CheckIsHidden(type)) return; - Color color = (GetAttribute(type) ?? _fakeDebugColorAttribute).GetUnityColor(); + //Color color = (GetAttribute(type) ?? _fakeDebugColorAttribute).GetUnityColor(); + Color color = EcsDebugUtility.GetColorRGB(type).ToUnityColor(); + GUILayout.BeginVertical(EcsEditor.GetStyle(color, 0.2f)); GUILayout.Label(EcsEditor.GetGenericName(type), EditorStyles.boldLabel); GUILayout.Label(string.Join(", ", runner.Targets.Cast().Select(o => o.GetType().Name)), systemsListStyle); diff --git a/src/EntityTemplate/EntityTemplateEditor.cs b/src/EntityTemplate/EntityTemplateEditor.cs index 78f66c3..35d073f 100644 --- a/src/EntityTemplate/EntityTemplateEditor.cs +++ b/src/EntityTemplate/EntityTemplateEditor.cs @@ -169,8 +169,9 @@ namespace DCFApixels.DragonECS Type type = browsable.GetType(); string name = browsableName == null ? type.Name : GetLastPathComponent(browsableName.Name); string description = customInitializer != null ? customInitializer.Description : initializerType.GetCustomAttribute()?.description; - Color panelColor = customInitializer != null ? customInitializer.Color : initializerType.GetCustomAttribute()?.GetUnityColor() ?? Color.black; - + // Color panelColor = customInitializer != null ? customInitializer.Color : initializerType.GetCustomAttribute()?.GetUnityColor() ?? Color.black; + Color panelColor = customInitializer != null ? customInitializer.Color : EcsDebugUtility.GetColorRGB(initializerType).ToUnityColor(); + GUILayout.BeginHorizontal(); GUILayout.BeginVertical(EcsEditor.GetStyle(panelColor, 0.2f)); diff --git a/src/EntityTemplate/TemplateComponent.cs b/src/EntityTemplate/TemplateComponent.cs index a2486c7..f9cb3c2 100644 --- a/src/EntityTemplate/TemplateComponent.cs +++ b/src/EntityTemplate/TemplateComponent.cs @@ -38,9 +38,10 @@ namespace DCFApixels.DragonECS #region Get meta internal static Color GetColor(Type type) { - var atr = type.GetCustomAttribute(); - if (atr == null) return Color.black; - return atr.GetUnityColor(); + //var atr = type.GetCustomAttribute(); + //if (atr == null) return Color.black; + //return atr.GetUnityColor(); + return EcsDebugUtility.GetColorRGB(type).ToUnityColor(); } internal static string GetName(Type type) { diff --git a/src/Extensions/Runners.cs b/src/Extensions/Runners.cs index 942136a..992136a 100644 --- a/src/Extensions/Runners.cs +++ b/src/Extensions/Runners.cs @@ -2,6 +2,18 @@ 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().DrawGizmos(systems); + } + } + public interface IEcsLateRunProcess : IEcsProcess { public void LateRun(EcsPipeline pipeline); @@ -27,6 +39,37 @@ namespace DCFApixels.DragonECS namespace Internal { + [DebugColor(DebugColor.Orange)] + public class EcsLateGizmosSystemRunner : EcsRunner, 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)] public class EcsLateRunSystemRunner : EcsRunner, IEcsLateRunProcess { diff --git a/src/Utils/DebugColorAttributeExt.cs b/src/Utils/DebugColorAttributeExt.cs index 86de672..a47c9df 100644 --- a/src/Utils/DebugColorAttributeExt.cs +++ b/src/Utils/DebugColorAttributeExt.cs @@ -12,5 +12,14 @@ namespace DCFApixels.DragonECS { 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); + } } }