2024-03-10 06:19:20 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
using DCFApixels.DragonECS.RunnersCore;
|
|
|
|
|
using DCFApixels.DragonECS.Unity.Internal;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS.Unity.Editors
|
|
|
|
|
{
|
|
|
|
|
[CustomEditor(typeof(PipelineMonitor))]
|
2024-09-14 23:30:11 +08:00
|
|
|
|
internal class PipelineMonitorEditor : ExtendedEditor<PipelineMonitor>
|
2024-03-10 06:19:20 +08:00
|
|
|
|
{
|
|
|
|
|
private GUIStyle _headerStyle;
|
|
|
|
|
private GUIStyle _interfacesStyle;
|
|
|
|
|
private Color _interfaceColor = new Color(0.96f, 1f, 0.16f);
|
|
|
|
|
|
|
|
|
|
private GUIStyle systemsListStyle;
|
|
|
|
|
|
2024-09-14 23:30:11 +08:00
|
|
|
|
protected override void DrawCustom()
|
2024-03-10 06:19:20 +08:00
|
|
|
|
{
|
|
|
|
|
systemsListStyle = new GUIStyle(EditorStyles.miniLabel);
|
|
|
|
|
systemsListStyle.wordWrap = true;
|
|
|
|
|
|
|
|
|
|
if (Target.Pipeline == null || Target.Pipeline.IsDestoryed)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (_headerStyle == null)
|
|
|
|
|
{
|
|
|
|
|
_headerStyle = new GUIStyle(EditorStyles.boldLabel);
|
|
|
|
|
_interfacesStyle = new GUIStyle(EditorStyles.miniLabel);
|
|
|
|
|
_interfacesStyle.hover.textColor = _interfaceColor;
|
|
|
|
|
_interfacesStyle.focused.textColor = _interfaceColor;
|
|
|
|
|
_interfacesStyle.active.textColor = _interfaceColor;
|
|
|
|
|
_interfacesStyle.normal.textColor = _interfaceColor;
|
|
|
|
|
_interfacesStyle.wordWrap = true;
|
|
|
|
|
_headerStyle.fontSize = 28;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GUILayout.Label("[Systems]", _headerStyle);
|
|
|
|
|
|
|
|
|
|
IsShowInterfaces = EditorGUILayout.Toggle("Show Interfaces", IsShowInterfaces);
|
|
|
|
|
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden);
|
|
|
|
|
|
2024-09-14 23:30:11 +08:00
|
|
|
|
using (EcsGUI.Layout.BeginVertical())
|
2024-03-10 06:19:20 +08:00
|
|
|
|
{
|
2024-09-14 23:30:11 +08:00
|
|
|
|
foreach (var item in Target.Pipeline.AllSystems)
|
|
|
|
|
{
|
|
|
|
|
DrawSystem(item);
|
|
|
|
|
}
|
2024-03-10 06:19:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GUILayout.Label("[Runners]", _headerStyle);
|
|
|
|
|
|
2024-09-14 23:30:11 +08:00
|
|
|
|
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f)))
|
2024-03-10 06:19:20 +08:00
|
|
|
|
{
|
2024-09-14 23:30:11 +08:00
|
|
|
|
foreach (var item in Target.Pipeline.AllRunners)
|
2024-03-10 06:19:20 +08:00
|
|
|
|
{
|
2024-09-14 23:30:11 +08:00
|
|
|
|
if (item.Key.IsInterface == false)
|
|
|
|
|
{
|
|
|
|
|
DrawRunner(item.Value);
|
|
|
|
|
}
|
2024-03-10 06:19:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void DrawSystem(IEcsProcess system)
|
|
|
|
|
{
|
|
|
|
|
if (system is SystemsLayerMarkerSystem markerSystem)
|
|
|
|
|
{
|
|
|
|
|
GUILayout.EndVertical();
|
|
|
|
|
GUILayout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f));
|
|
|
|
|
|
2024-09-14 23:30:11 +08:00
|
|
|
|
using (EcsGUI.Layout.BeginHorizontal()) using (var scope = EcsGUI.SetAlignment(GUI.skin.label))
|
2024-06-25 23:20:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-25 23:27:29 +08:00
|
|
|
|
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * -4f);
|
2024-06-25 23:20:40 +08:00
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
2024-03-10 06:19:20 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Type type = system.GetType();
|
|
|
|
|
TypeMeta meta = type.ToMeta();
|
|
|
|
|
|
|
|
|
|
if (CheckIsHidden(meta))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string name = meta.Name;
|
|
|
|
|
Color color = meta.Color.ToUnityColor();
|
|
|
|
|
|
2024-09-14 23:30:11 +08:00
|
|
|
|
|
|
|
|
|
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(color, 0.2f)))
|
2024-03-10 06:19:20 +08:00
|
|
|
|
{
|
2024-09-14 23:30:11 +08:00
|
|
|
|
if (IsShowInterfaces)
|
|
|
|
|
{
|
|
|
|
|
GUILayout.Label(string.Join(", ", type.GetInterfaces().Select(o => o.Name)), _interfacesStyle);
|
|
|
|
|
}
|
|
|
|
|
GUILayout.Label(name, EditorStyles.boldLabel);
|
2024-03-10 06:19:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void DrawRunner(IEcsRunner runner)
|
|
|
|
|
{
|
|
|
|
|
Type type = runner.GetType();
|
|
|
|
|
TypeMeta meta = type.ToMeta();
|
|
|
|
|
|
|
|
|
|
if (CheckIsHidden(meta))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Color color = meta.Color.ToUnityColor();
|
|
|
|
|
|
2024-09-14 23:30:11 +08:00
|
|
|
|
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(color, 0.2f)))
|
|
|
|
|
{
|
|
|
|
|
GUILayout.Label(meta.Name, EditorStyles.boldLabel);
|
|
|
|
|
GUILayout.Label(string.Join(", ", runner.ProcessRaw.Cast<object>().Select(o => o.GetType().Name)), systemsListStyle);
|
|
|
|
|
}
|
2024-03-10 06:19:20 +08:00
|
|
|
|
}
|
|
|
|
|
private bool CheckIsHidden(TypeMeta meta)
|
|
|
|
|
{
|
|
|
|
|
if (IsShowHidden)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return meta.IsHidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|