mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 17:34:34 +08:00
add copy to clipboard
This commit is contained in:
parent
5bc8e9f0a5
commit
1ec556d8e4
@ -19,6 +19,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
|
||||
private void CopyToClipboard()
|
||||
{
|
||||
const char SEPARATOR = '\t';
|
||||
|
||||
var all = Target.Pipeline.AllSystems;
|
||||
string[] names = new string[all.Length];
|
||||
for (int i = 0; i < all.Length; i++)
|
||||
@ -41,7 +43,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
color = EcsGUI.SelectPanelColor(meta, i, -1).ToMetaColor();
|
||||
}
|
||||
name = $"{meta.Name} : {meta.TypeName} : {meta.MetaID} : {color.colorCode:X8}";
|
||||
name = $"{meta.Name}{SEPARATOR}{meta.TypeName}{SEPARATOR}{meta.MetaID}{SEPARATOR}{color.colorCode:X8}";
|
||||
}
|
||||
names[i] = name;
|
||||
}
|
||||
|
@ -1,14 +1,122 @@
|
||||
#if UNITY_EDITOR
|
||||
using DCFApixels.DragonECS.UncheckedCore;
|
||||
using DCFApixels.DragonECS.Unity.Internal;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
[CustomEditor(typeof(WorldMonitor))]
|
||||
internal class WorldMonitorEditor : ExtendedEditor<WorldMonitor>
|
||||
{
|
||||
private GUIStyle _headerStyle;
|
||||
|
||||
private void CopyToClipboard()
|
||||
{
|
||||
const char SEPARATOR = '\t';
|
||||
|
||||
var world = Target.World;
|
||||
EntitesMatrix mtrx = new EntitesMatrix(world);
|
||||
|
||||
var allpools = world.AllPools.Slice(0, world.PoolsCount);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int i = -1;
|
||||
|
||||
int entitiesCount = world.Entities.Count;
|
||||
|
||||
//numbers
|
||||
sb.Append($"{SEPARATOR}{SEPARATOR}№");
|
||||
i = -1;
|
||||
foreach (var pool in allpools)
|
||||
{
|
||||
i++;
|
||||
sb.Append($"{SEPARATOR}{i}");
|
||||
}
|
||||
sb.Append("\r\n");
|
||||
//numbers end
|
||||
|
||||
//chunks
|
||||
sb.Append($"{SEPARATOR}{SEPARATOR}Chunks");
|
||||
i = -1;
|
||||
foreach (var pool in allpools)
|
||||
{
|
||||
i++;
|
||||
sb.Append($"{SEPARATOR}{i >> 5}");
|
||||
}
|
||||
sb.Append("\r\n");
|
||||
//chunks end
|
||||
|
||||
|
||||
//header
|
||||
sb.Append($"Entity{SEPARATOR}Gen{SEPARATOR}Count");
|
||||
|
||||
//pools
|
||||
foreach (var pool in allpools)
|
||||
{
|
||||
sb.Append($"{SEPARATOR}");
|
||||
if (pool.IsNullOrDummy() == false)
|
||||
{
|
||||
sb.Append(pool.ComponentType.ToMeta().TypeName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("NULL");
|
||||
}
|
||||
}
|
||||
sb.Append("\r\n");
|
||||
//header end
|
||||
|
||||
|
||||
//content
|
||||
for (i = 0; i < mtrx.EntitesCount; i++)
|
||||
{
|
||||
if (mtrx.IsEntityUsed(i))
|
||||
{
|
||||
sb.Append($"{i}{SEPARATOR}{mtrx.GetEntityGen(i)}{SEPARATOR}{mtrx.GetEntityComponentsCount(i)}");
|
||||
for (int j = 0; j < mtrx.PoolsCount; j++)
|
||||
{
|
||||
if (mtrx[i, j])
|
||||
{
|
||||
sb.Append($"{SEPARATOR}+");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append($"{SEPARATOR}");
|
||||
}
|
||||
}
|
||||
sb.Append("\r\n");
|
||||
entitiesCount--;
|
||||
}
|
||||
|
||||
if (entitiesCount <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
//end
|
||||
|
||||
GUIUtility.systemCopyBuffer = sb.ToString();
|
||||
}
|
||||
|
||||
protected override void DrawCustom()
|
||||
{
|
||||
if (_headerStyle == null)
|
||||
{
|
||||
_headerStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
_headerStyle.fontSize = 28;
|
||||
}
|
||||
|
||||
using (EcsGUI.Layout.BeginHorizontal())
|
||||
{
|
||||
GUILayout.Label("[World]", _headerStyle, GUILayout.ExpandWidth(true));
|
||||
if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
|
||||
{
|
||||
CopyToClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EcsGUI.Layout.DrawWorldBaseInfo(Target.World);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using DCFApixels.DragonECS.Core;
|
||||
using DCFApixels.DragonECS.Unity.Internal;
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@ -10,10 +11,120 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
[CustomEditor(typeof(WorldQueriesMonitor))]
|
||||
internal class WorldQueriesMonitorEditor : ExtendedEditor<WorldQueriesMonitor>
|
||||
{
|
||||
private GUIStyle _headerStyle;
|
||||
|
||||
private void CopyToClipboard()
|
||||
{
|
||||
const char SEPARATOR = '\t';
|
||||
var allqueries = Target.MaskQueryExecutors;
|
||||
var allpools = Target.World.AllPools.Slice(0, Target.World.PoolsCount);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int i = -1;
|
||||
|
||||
//numbers
|
||||
sb.Append($"{SEPARATOR}{SEPARATOR}№");
|
||||
i = -1;
|
||||
foreach (var pool in allpools)
|
||||
{
|
||||
i++;
|
||||
sb.Append($"{SEPARATOR}{i}");
|
||||
}
|
||||
sb.Append("\r\n");
|
||||
//numbers end
|
||||
|
||||
//chunks
|
||||
sb.Append($"{SEPARATOR}{SEPARATOR}Chunks");
|
||||
i = -1;
|
||||
foreach (var pool in allpools)
|
||||
{
|
||||
i++;
|
||||
sb.Append($"{SEPARATOR}{i >> 5}");
|
||||
}
|
||||
sb.Append("\r\n");
|
||||
//chunks end
|
||||
|
||||
|
||||
//header
|
||||
sb.Append($"№{SEPARATOR}Version{SEPARATOR}Count");
|
||||
|
||||
//pools
|
||||
foreach (var pool in allpools)
|
||||
{
|
||||
sb.Append($"{SEPARATOR}");
|
||||
if (pool.IsNullOrDummy() == false)
|
||||
{
|
||||
sb.Append(pool.ComponentType.ToMeta().TypeName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("NULL");
|
||||
}
|
||||
}
|
||||
sb.Append("\r\n");
|
||||
//header end
|
||||
|
||||
|
||||
//content
|
||||
i = -1;
|
||||
foreach (var query in allqueries)
|
||||
{
|
||||
i++;
|
||||
|
||||
sb.Append($"{i}{SEPARATOR}{query.Version}{SEPARATOR}{query.LastCachedCount}");
|
||||
|
||||
var incs = query.Mask.Incs;
|
||||
var excs = query.Mask.Excs;
|
||||
var incsI = 0;
|
||||
var excsI = 0;
|
||||
for (int j = 0; j < allpools.Length; j++)
|
||||
{
|
||||
var pool = allpools[j];
|
||||
|
||||
sb.Append($"{SEPARATOR}");
|
||||
if (pool.IsNullOrDummy() == false)
|
||||
{
|
||||
if (incsI < incs.Length && incs[incsI] == j)
|
||||
{
|
||||
sb.Append($"+");
|
||||
incsI++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (excsI < excs.Length && excs[excsI] == j)
|
||||
{
|
||||
sb.Append($"-");
|
||||
excsI++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.Append("\r\n");
|
||||
}
|
||||
|
||||
//end
|
||||
|
||||
GUIUtility.systemCopyBuffer = sb.ToString();
|
||||
}
|
||||
|
||||
protected override void DrawCustom()
|
||||
{
|
||||
if (_headerStyle == null)
|
||||
{
|
||||
_headerStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
_headerStyle.fontSize = 28;
|
||||
}
|
||||
var executors = Target.MaskQueryExecutors;
|
||||
|
||||
using (EcsGUI.Layout.BeginHorizontal())
|
||||
{
|
||||
GUILayout.Label("[Queries]", _headerStyle, GUILayout.ExpandWidth(true));
|
||||
if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
|
||||
{
|
||||
CopyToClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.IntField("Count: ", executors.Count);
|
||||
GUILayout.Space(20);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user