mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
update style
This commit is contained in:
parent
7b1cad6e2b
commit
3f75ec5f98
@ -77,7 +77,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawSystem(IEcsProcess system)
|
private void DrawSystem(IEcsProcess system)
|
||||||
{
|
{
|
||||||
if (system is SystemsLayerMarkerSystem markerSystem)
|
if (system is SystemsLayerMarkerSystem markerSystem)
|
||||||
@ -112,7 +111,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
GUILayout.Label(name, EditorStyles.boldLabel);
|
GUILayout.Label(name, EditorStyles.boldLabel);
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawRunner(IEcsRunner runner)
|
private void DrawRunner(IEcsRunner runner)
|
||||||
{
|
{
|
||||||
Type type = runner.GetType();
|
Type type = runner.GetType();
|
||||||
@ -122,8 +120,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Color color = (GetAttribute<DebugColorAttribute>(type) ?? _fakeDebugColorAttribute).GetUnityColor();
|
|
||||||
Color color = meta.Color.ToUnityColor();
|
Color color = meta.Color.ToUnityColor();
|
||||||
|
|
||||||
GUILayout.BeginVertical(UnityEditorUtility.GetStyle(color, 0.2f));
|
GUILayout.BeginVertical(UnityEditorUtility.GetStyle(color, 0.2f));
|
||||||
@ -131,15 +127,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
GUILayout.Label(string.Join(", ", runner.ProcessRaw.Cast<object>().Select(o => o.GetType().Name)), systemsListStyle);
|
GUILayout.Label(string.Join(", ", runner.ProcessRaw.Cast<object>().Select(o => o.GetType().Name)), systemsListStyle);
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TAttribute GetAttribute<TAttribute>(Type target) where TAttribute : Attribute
|
|
||||||
{
|
|
||||||
var result = target.GetCustomAttributes(_debugColorAttributeType, false);
|
|
||||||
if (result.Length > 0)
|
|
||||||
return (TAttribute)result[0];
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool CheckIsHidden(TypeMeta meta)
|
private bool CheckIsHidden(TypeMeta meta)
|
||||||
{
|
{
|
||||||
if (IsShowHidden)
|
if (IsShowHidden)
|
||||||
|
@ -12,11 +12,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
[CustomEditor(typeof(PipelineProcessMonitor))]
|
[CustomEditor(typeof(PipelineProcessMonitor))]
|
||||||
internal class PipelineProcessesMonitorEditor : Editor
|
internal class PipelineProcessesMonitorEditor : Editor
|
||||||
{
|
{
|
||||||
|
private static Type SYSTEM_INTERFACE_TYPE = typeof(IEcsProcess);
|
||||||
|
|
||||||
private bool _isInit = false;
|
private bool _isInit = false;
|
||||||
private List<ProcessData> _processesList = new List<ProcessData>();
|
private List<ProcessData> _processList = new List<ProcessData>();
|
||||||
private Dictionary<Type, int> _processeIndexes = new Dictionary<Type, int>();
|
private Dictionary<Type, int> _processeIndexes = new Dictionary<Type, int>();
|
||||||
private Type systemInterfaceType = typeof(IEcsProcess);
|
private SystemData[] _systemsList;
|
||||||
private IEcsProcess[] _systems;
|
|
||||||
|
|
||||||
private PipelineProcessMonitor Target => (PipelineProcessMonitor)target;
|
private PipelineProcessMonitor Target => (PipelineProcessMonitor)target;
|
||||||
private bool IsShowInterfaces
|
private bool IsShowInterfaces
|
||||||
@ -37,45 +38,39 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_processesList.Clear();
|
_processList.Clear();
|
||||||
_processeIndexes.Clear();
|
_processeIndexes.Clear();
|
||||||
|
IEnumerable<IEcsProcess> fileretSystems = Target.Pipeline.AllSystems;
|
||||||
if (IsShowHidden)
|
if (IsShowHidden)
|
||||||
{
|
{ fileretSystems = fileretSystems.Where(o => o is SystemsLayerMarkerSystem == false); }
|
||||||
_systems = Target.Pipeline.AllSystems.Where(o => o is SystemsLayerMarkerSystem == false).ToArray();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{ fileretSystems = fileretSystems.Where(o => o.GetMeta().IsHidden == false); }
|
||||||
_systems = Target.Pipeline.AllSystems.Where(o => o.GetMeta().IsHidden == false).ToArray();
|
_systemsList = fileretSystems.Select(o => new SystemData(o.GetMeta(), o)).ToArray();
|
||||||
}
|
|
||||||
|
|
||||||
int i = 0;
|
for (int i = 0; i < _systemsList.Length; i++)
|
||||||
foreach (var system in _systems)
|
|
||||||
{
|
{
|
||||||
foreach (var interfaceType in system.GetType().GetInterfaces())
|
var system = _systemsList[i];
|
||||||
|
foreach (var interfaceType in system.meta.Type.GetInterfaces())
|
||||||
{
|
{
|
||||||
TypeMeta meta = interfaceType.ToMeta();
|
TypeMeta meta = interfaceType.ToMeta();
|
||||||
if (systemInterfaceType.IsAssignableFrom(interfaceType) && systemInterfaceType != interfaceType && (IsShowHidden || meta.IsHidden == false))
|
if (SYSTEM_INTERFACE_TYPE.IsAssignableFrom(interfaceType) && SYSTEM_INTERFACE_TYPE != interfaceType && (IsShowHidden || meta.IsHidden == false))
|
||||||
{
|
{
|
||||||
ProcessData data;
|
ProcessData data;
|
||||||
if (!_processeIndexes.TryGetValue(interfaceType, out int index))
|
if (_processeIndexes.TryGetValue(interfaceType, out int index) == false)
|
||||||
{
|
{
|
||||||
index = _processesList.Count;
|
index = _processList.Count;
|
||||||
_processeIndexes.Add(interfaceType, index);
|
_processeIndexes.Add(interfaceType, index);
|
||||||
|
|
||||||
data = new ProcessData();
|
data = new ProcessData();
|
||||||
_processesList.Add(data);
|
data.interfaceMeta = meta;
|
||||||
|
data.systemsBitMask = new BitMask(_systemsList.Length);
|
||||||
data.name = meta.Name;
|
_processList.Add(data);
|
||||||
data.interfaceType = interfaceType;
|
|
||||||
data.systemsBitMask = new BitMask(_systems.Length);
|
|
||||||
}
|
}
|
||||||
data = _processesList[index];
|
data = _processList[index];
|
||||||
data.systemsBitMask[i] = true;
|
data.systemsBitMask[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_isInit = true;
|
_isInit = true;
|
||||||
}
|
}
|
||||||
private Vector2 _position;
|
private Vector2 _position;
|
||||||
@ -90,94 +85,112 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
_isInit = false;
|
_isInit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
Rect rect;
|
|
||||||
Rect lineRect;
|
|
||||||
GUILayout.Label("", GUILayout.ExpandWidth(true), GUILayout.Height(400f));
|
GUILayout.Label("", GUILayout.ExpandWidth(true), GUILayout.Height(400f));
|
||||||
rect = GUILayoutUtility.GetLastRect();
|
Rect rect = GUILayoutUtility.GetLastRect();
|
||||||
|
|
||||||
rect.height = 400f;
|
rect.height = 400f;
|
||||||
|
|
||||||
|
|
||||||
Rect rectView = new Rect(0f, 0f, _nameCellSize.x + _cellsize.x * _processesList.Count, _nameCellSize.y + _cellsize.y * _systems.Length);
|
Rect rectView = new Rect(0f, 0f, _nameCellSize.x + _cellsize.x * _processList.Count, _nameCellSize.y + _cellsize.y * _systemsList.Length);
|
||||||
|
EditorGUI.DrawRect(rect, new Color(0, 0, 0, 0.6f));
|
||||||
_position = GUI.BeginScrollView(rect, _position, rectView, true, true);
|
_position = GUI.BeginScrollView(rect, _position, rectView, true, true);
|
||||||
|
//var blackStyle = UnityEditorUtility.GetStyle(Color.black, 0.04f);
|
||||||
List<string> systeNames = new List<string>();
|
//var whiteStyle = UnityEditorUtility.GetStyle(Color.white, 0.04f);
|
||||||
|
|
||||||
var blackStyle = UnityEditorUtility.GetStyle(Color.black, 0.04f);
|
|
||||||
var whiteStyle = UnityEditorUtility.GetStyle(Color.white, 0.04f);
|
|
||||||
GUIContent label = new GUIContent();
|
|
||||||
|
|
||||||
|
|
||||||
Vector2 pivod = _nameCellSize;
|
Vector2 pivod = _nameCellSize;
|
||||||
rect = new Rect();
|
rect = default;
|
||||||
rect.y = _nameCellSize.y;
|
rect.y = _nameCellSize.y;
|
||||||
rect.width = _nameCellSize.x;
|
rect.width = _nameCellSize.x;
|
||||||
rect.height = _cellsize.x;
|
rect.height = _cellsize.x;
|
||||||
rect.y -= _cellsize.y;
|
rect.y -= _cellsize.y;
|
||||||
for (int i = 0; i < _processesList.Count; i++)
|
//processes line
|
||||||
|
for (int i = 0; i < _processList.Count; i++)
|
||||||
{
|
{
|
||||||
lineRect = rect;
|
TypeMeta meta = _processList[i].interfaceMeta;
|
||||||
|
Rect lineRect = rect;
|
||||||
lineRect.y = 0f;
|
lineRect.y = 0f;
|
||||||
lineRect.x = _nameCellSize.x + _cellsize.x * i;
|
lineRect.x = _nameCellSize.x + _cellsize.x * i;
|
||||||
lineRect.width = _cellsize.x;
|
lineRect.width = _cellsize.x;
|
||||||
lineRect.height = rectView.height;
|
lineRect.height = rectView.height;
|
||||||
GUI.Label(lineRect, "", i % 2 == 1 ? whiteStyle : blackStyle);
|
lineRect = RectUtility.AddPadding(lineRect, 1, 0);
|
||||||
|
//GUI.Label(lineRect, "", i % 2 == 1 ? whiteStyle : blackStyle);
|
||||||
|
Color color = meta.Color.ToUnityColor();
|
||||||
|
color = NormalizeGridColor(i, color);
|
||||||
|
EditorGUI.DrawRect(lineRect, color);
|
||||||
|
|
||||||
GUIUtility.RotateAroundPivot(90, pivod);
|
GUIUtility.RotateAroundPivot(90, pivod);
|
||||||
label.text = _processesList[i].name;
|
GUI.Label(rect, UnityEditorUtility.GetLabel(meta.Name), EditorStyles.miniBoldLabel);
|
||||||
label.tooltip = "." + _processesList[i].name;
|
|
||||||
GUI.Label(rect, label, EditorStyles.miniBoldLabel);
|
|
||||||
GUIUtility.RotateAroundPivot(-90, pivod);
|
GUIUtility.RotateAroundPivot(-90, pivod);
|
||||||
|
|
||||||
pivod.x += _cellsize.x;
|
pivod.x += _cellsize.x;
|
||||||
rect.x += _cellsize.x;
|
rect.x += _cellsize.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
rect = new Rect();
|
rect = default;
|
||||||
rect.y = _nameCellSize.y;
|
rect.y = _nameCellSize.y;
|
||||||
rect.width = _nameCellSize.x;
|
rect.width = _nameCellSize.x;
|
||||||
rect.height = _cellsize.x;
|
rect.height = _cellsize.x;
|
||||||
for (int i = 0; i < _systems.Length; i++)
|
//systems line
|
||||||
|
for (int i = 0; i < _systemsList.Length; i++)
|
||||||
{
|
{
|
||||||
TypeMeta meta = _systems[i].GetMeta();
|
TypeMeta meta = _systemsList[i].meta;
|
||||||
string name = meta.Name;
|
string name = meta.Name;
|
||||||
systeNames.Add(name);
|
|
||||||
|
|
||||||
lineRect = rect;
|
Rect lineRect = rect;
|
||||||
lineRect.width = rectView.width;
|
lineRect.width = rectView.width;
|
||||||
GUI.Label(lineRect, "", i % 2 == 1 ? whiteStyle : blackStyle);
|
lineRect = RectUtility.AddPadding(lineRect, 0, 1);
|
||||||
|
//GUI.Label(lineRect, "", i % 2 == 1 ? whiteStyle : blackStyle);
|
||||||
|
Color color = meta.Color.ToUnityColor();
|
||||||
|
color = NormalizeGridColor(i, color);
|
||||||
|
EditorGUI.DrawRect(lineRect, color);
|
||||||
|
|
||||||
label.text = name;
|
GUI.Label(rect, UnityEditorUtility.GetLabel(name, i + " " + name), EditorStyles.miniBoldLabel);
|
||||||
label.tooltip = i + " " + name;
|
|
||||||
GUI.Label(rect, label, EditorStyles.miniBoldLabel);
|
|
||||||
rect.y += _cellsize.y;
|
rect.y += _cellsize.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = 0; x < _processesList.Count; x++)
|
//matrix
|
||||||
|
for (int x = 0; x < _processList.Count; x++)
|
||||||
{
|
{
|
||||||
var process = _processesList[x];
|
var process = _processList[x];
|
||||||
for (int y = 0; y < _systems.Length; y++)
|
for (int y = 0; y < _systemsList.Length; y++)
|
||||||
{
|
{
|
||||||
string systemName = systeNames[x];
|
|
||||||
rect = new Rect(x * _cellsize.x + _nameCellSize.x, y * _cellsize.y + _nameCellSize.y, _cellsize.x, _cellsize.y);
|
rect = new Rect(x * _cellsize.x + _nameCellSize.x, y * _cellsize.y + _nameCellSize.y, _cellsize.x, _cellsize.y);
|
||||||
bool flag = process.systemsBitMask[y];
|
bool flag = process.systemsBitMask[y];
|
||||||
string labeltext = flag ? "^" : " ";
|
string labeltext = flag ? "^" : " ";
|
||||||
label.text = labeltext;
|
GUI.Label(rect, UnityEditorUtility.GetLabel(labeltext, $"{process.interfaceMeta.Name}-{_systemsList[x].meta.Name}"));
|
||||||
label.tooltip = $"{process.name}-{systemName}";
|
|
||||||
GUI.Label(rect, label);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.EndScrollView();
|
GUI.EndScrollView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Color NormalizeGridColor(int index, Color color)
|
||||||
|
{
|
||||||
|
if (index % 2 == 1)
|
||||||
|
{
|
||||||
|
color = color / 1.4f;
|
||||||
|
color.a = 0.3f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
color.a = 0.5f;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
private class SystemData
|
||||||
|
{
|
||||||
|
public TypeMeta meta;
|
||||||
|
public IEcsProcess system;
|
||||||
|
public SystemData(TypeMeta meta, IEcsProcess system)
|
||||||
|
{
|
||||||
|
this.meta = meta;
|
||||||
|
this.system = system;
|
||||||
|
}
|
||||||
|
}
|
||||||
private class ProcessData
|
private class ProcessData
|
||||||
{
|
{
|
||||||
public Type interfaceType;
|
public TypeMeta interfaceMeta;
|
||||||
public string name;
|
|
||||||
public BitMask systemsBitMask;
|
public BitMask systemsBitMask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Label
|
#region Label
|
||||||
|
public static GUIContent GetLabelTemp()
|
||||||
|
{
|
||||||
|
if (_singletonContent == null)
|
||||||
|
{
|
||||||
|
_singletonContent = new GUIContent();
|
||||||
|
}
|
||||||
|
return _singletonContent;
|
||||||
|
}
|
||||||
public static GUIContent GetLabel(string name, string tooltip = null)
|
public static GUIContent GetLabel(string name, string tooltip = null)
|
||||||
{
|
{
|
||||||
if (_singletonContent == null)
|
if (_singletonContent == null)
|
||||||
|
@ -14,7 +14,7 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
|||||||
r = r + (gray - r) * (1 - t);
|
r = r + (gray - r) * (1 - t);
|
||||||
g = g + (gray - g) * (1 - t);
|
g = g + (gray - g) * (1 - t);
|
||||||
b = b + (gray - b) * (1 - t);
|
b = b + (gray - b) * (1 - t);
|
||||||
return new Color(r, g, b);
|
return new Color(r, g, b, self.a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user