From f2ca8f01828236d0cb46c60a113d96df0b84d3c3 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Tue, 25 Jun 2024 23:20:40 +0800 Subject: [PATCH] update pipeline monitor --- src/Consts.cs | 2 + src/Debug/DebugModule.cs | 5 +- .../Monitors/Editor/PipelineMonitorEditor.cs | 24 +++++- src/Internal/Editor/EcsGUI.cs | 86 +++++++++++++------ 4 files changed, 86 insertions(+), 31 deletions(-) diff --git a/src/Consts.cs b/src/Consts.cs index 95fbc8a..aef5ffa 100644 --- a/src/Consts.cs +++ b/src/Consts.cs @@ -4,5 +4,7 @@ { public const string PACK_GROUP = "_" + EcsConsts.FRAMEWORK_NAME + "/Unity"; public const string ENTITY_BUILDING_GROUP = "Entity Building"; + + public const string DEBUG_LAYER = EcsConsts.NAME_SPACE + "Unity." + nameof(DEBUG_LAYER); } } diff --git a/src/Debug/DebugModule.cs b/src/Debug/DebugModule.cs index 9dd0438..a25c029 100644 --- a/src/Debug/DebugModule.cs +++ b/src/Debug/DebugModule.cs @@ -1,10 +1,11 @@ -using DCFApixels.DragonECS.Unity.Internal; +using DCFApixels.DragonECS.Unity; +using DCFApixels.DragonECS.Unity.Internal; namespace DCFApixels.DragonECS { public sealed class DebugModule : IEcsModule { - public const string DEBUG_LAYER = nameof(DEBUG_LAYER); + public const string DEBUG_LAYER = EcsUnityConsts.DEBUG_LAYER; public EcsWorld[] _worlds; public DebugModule(params EcsWorld[] worlds) { diff --git a/src/Debug/Monitors/Editor/PipelineMonitorEditor.cs b/src/Debug/Monitors/Editor/PipelineMonitorEditor.cs index 9936e29..ac357b0 100644 --- a/src/Debug/Monitors/Editor/PipelineMonitorEditor.cs +++ b/src/Debug/Monitors/Editor/PipelineMonitorEditor.cs @@ -85,9 +85,27 @@ namespace DCFApixels.DragonECS.Unity.Editors GUILayout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f)); GUILayout.BeginHorizontal(); - GUILayout.Label("<"); - GUILayout.Label($"{markerSystem.name}", EditorStyles.boldLabel); - GUILayout.Label(">", GUILayout.ExpandWidth(false)); + using (var scope = EcsGUI.SetAlignment(GUI.skin.label)) + { + + scope.Target.alignment = TextAnchor.UpperLeft; + GUILayout.Label("<", GUILayout.ExpandWidth(true)); + scope.Target.alignment = TextAnchor.UpperRight; + using (EcsGUI.SetAlpha(0.64f)) + { + GUILayout.Label($"{markerSystem.layerNameSpace}", GUILayout.ExpandWidth(false)); + } + + EcsGUI.Layout.RemoveDefaultSpacingDouble(); + + scope.Target.alignment = TextAnchor.UpperLeft; + using (EcsGUI.SetFontStyle(scope.Target, FontStyle.Bold)) + { + GUILayout.Label($"{markerSystem.layerName}", GUILayout.ExpandWidth(false)); + } + scope.Target.alignment = TextAnchor.UpperRight; + GUILayout.Label(">", GUILayout.ExpandWidth(true)); + } GUILayout.EndHorizontal(); return; } diff --git a/src/Internal/Editor/EcsGUI.cs b/src/Internal/Editor/EcsGUI.cs index b5566f8..58273b8 100644 --- a/src/Internal/Editor/EcsGUI.cs +++ b/src/Internal/Editor/EcsGUI.cs @@ -20,10 +20,7 @@ namespace DCFApixels.DragonECS.Unity.Editors _value = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = value; } - public void Dispose() - { - EditorGUIUtility.labelWidth = _value; - } + public void Dispose() { EditorGUIUtility.labelWidth = _value; } } public struct ColorScope : IDisposable { @@ -34,10 +31,7 @@ namespace DCFApixels.DragonECS.Unity.Editors _value = GUI.color; GUI.color = value; } - public void Dispose() - { - GUI.color = _value; - } + public void Dispose() { GUI.color = _value; } } public struct ContentColorScope : IDisposable { @@ -48,10 +42,7 @@ namespace DCFApixels.DragonECS.Unity.Editors _value = GUI.contentColor; GUI.contentColor = value; } - public void Dispose() - { - GUI.contentColor = _value; - } + public void Dispose() { GUI.contentColor = _value; } } public struct BackgroundColorScope : IDisposable { @@ -62,10 +53,7 @@ namespace DCFApixels.DragonECS.Unity.Editors _value = GUI.backgroundColor; GUI.backgroundColor = value; } - public void Dispose() - { - GUI.backgroundColor = _value; - } + public void Dispose() { GUI.backgroundColor = _value; } } public struct IndentLevelScope : IDisposable { @@ -75,29 +63,67 @@ namespace DCFApixels.DragonECS.Unity.Editors _value = EditorGUI.indentLevel; EditorGUI.indentLevel = value; } - public void Dispose() - { - EditorGUI.indentLevel = _value; - } + public void Dispose() { EditorGUI.indentLevel = _value; } } public struct AlignmentScope : IDisposable { - private readonly GUIStyle _target; + public readonly GUIStyle Target; private readonly TextAnchor _value; public AlignmentScope(GUIStyle target, TextAnchor value) { - _target = target; - _value = _target.alignment; - _target.alignment = value; + Target = target; + _value = Target.alignment; + Target.alignment = value; } - public void Dispose() + public AlignmentScope(GUIStyle target) { - _target.alignment = _value; + Target = target; + _value = Target.alignment; } + public void Dispose() { Target.alignment = _value; } + } + public struct FontSizeScope : IDisposable + { + public readonly GUIStyle Target; + private readonly int _value; + public FontSizeScope(GUIStyle target, int value) + { + Target = target; + _value = Target.fontSize; + Target.fontSize = value; + } + public FontSizeScope(GUIStyle target) + { + Target = target; + _value = Target.fontSize; + } + public void Dispose() { Target.fontSize = _value; } + } + public struct FontStyleScope : IDisposable + { + public readonly GUIStyle Target; + private readonly FontStyle _value; + public FontStyleScope(GUIStyle target, FontStyle value) + { + Target = target; + _value = Target.fontStyle; + Target.fontStyle = value; + } + public FontStyleScope(GUIStyle target) + { + Target = target; + _value = Target.fontStyle; + } + public void Dispose() { Target.fontStyle = _value; } } #endregion + public static FontStyleScope SetFontStyle(GUIStyle target, FontStyle value) => new FontStyleScope(target, value); + public static FontStyleScope SetFontStyle(GUIStyle target) => new FontStyleScope(target); + public static FontSizeScope SetFontSize(GUIStyle target, int value) => new FontSizeScope(target, value); + public static FontSizeScope SetFontSize(GUIStyle target) => new FontSizeScope(target); public static AlignmentScope SetAlignment(GUIStyle target, TextAnchor value) => new AlignmentScope(target, value); + public static AlignmentScope SetAlignment(GUIStyle target) => new AlignmentScope(target); public static IndentLevelScope SetIndentLevel(int level) => new IndentLevelScope(level); public static ContentColorScope SetContentColor(Color value) => new ContentColorScope(value); public static ContentColorScope SetContentColor(float r, float g, float b, float a = 1f) => new ContentColorScope(r, g, b, a); @@ -451,6 +477,14 @@ namespace DCFApixels.DragonECS.Unity.Editors public static class Layout { + public static void RemoveDefaultSpacingDouble() + { + GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * -2f); + } + public static void RemoveDefaultSpacing() + { + GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * -1f); + } public static void ScriptAssetButton(MonoScript script, params GUILayoutOption[] options) { EcsGUI.ScriptAssetButton(GUILayoutUtility.GetRect(UnityEditorUtility.GetLabelTemp(), EditorStyles.miniButton, options), script);