mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 10:04:36 +08:00
Update EditorUtility.cs
This commit is contained in:
parent
21f041bd44
commit
4afce1c448
@ -65,77 +65,25 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
internal readonly static Color GreenColor = new Color32(75, 255, 0, 255);
|
internal readonly static Color GreenColor = new Color32(75, 255, 0, 255);
|
||||||
internal readonly static Color RedColor = new Color32(255, 0, 75, 255);
|
internal readonly static Color RedColor = new Color32(255, 0, 75, 255);
|
||||||
|
|
||||||
//private static GUIStyle _grayStyle;
|
//private static GUILayoutOption[] _defaultParams;
|
||||||
//private static GUIStyle _greenStyle;
|
//private static bool _isInit = false;
|
||||||
//private static GUIStyle _redStyle;
|
//private static void Init()
|
||||||
private static GUILayoutOption[] _defaultParams;
|
|
||||||
|
|
||||||
private static bool _isInit = false;
|
|
||||||
|
|
||||||
private static void Init()
|
|
||||||
{
|
|
||||||
if (_isInit)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_defaultParams = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
|
|
||||||
//_grayStyle = EcsEditor.GetStyle(GrayColor);
|
|
||||||
//_greenStyle = EcsEditor.GetStyle(GreenColor);
|
|
||||||
//_redStyle = EcsEditor.GetStyle(RedColor);
|
|
||||||
_isInit = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//private const string CONNECTED = "Connected";
|
|
||||||
//private const string NOT_CONNECTED = "Not connected";
|
|
||||||
//private const string UNDETERMINED_CONNECTED = "---";
|
|
||||||
//public static void DrawConnectStatus(Rect position, bool status)
|
|
||||||
//{
|
//{
|
||||||
// Init();
|
// if (_isInit)
|
||||||
// if (status)
|
|
||||||
// {
|
// {
|
||||||
// GUI.Box(position, CONNECTED, _greenStyle);
|
// return;
|
||||||
// }
|
// }
|
||||||
// else
|
// _defaultParams = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
|
||||||
// {
|
// _isInit = true;
|
||||||
// GUI.Box(position, NOT_CONNECTED, _redStyle);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//public static void DrawUndeterminedConnectStatus(Rect position)
|
|
||||||
//{
|
|
||||||
// Init();
|
|
||||||
// GUI.Box(position, UNDETERMINED_CONNECTED, _grayStyle);
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public static class Layout
|
public static class Layout
|
||||||
{
|
{
|
||||||
//public static void DrawConnectStatus(bool status, params GUILayoutOption[] options)
|
private static bool IsShowHidden
|
||||||
//{
|
{
|
||||||
// Init();
|
get { return DebugMonitorPrefs.instance.IsShowHidden; }
|
||||||
// if (options == null || options.Length <= 0)
|
set { DebugMonitorPrefs.instance.IsShowHidden = value; }
|
||||||
// {
|
}
|
||||||
// options = _defaultParams;
|
|
||||||
// }
|
|
||||||
// GUILayout.Box("", options);
|
|
||||||
// Rect lastRect = GUILayoutUtility.GetLastRect();
|
|
||||||
// Color color = status ? GreenColor : RedColor;
|
|
||||||
// string text = status ? CONNECTED : NOT_CONNECTED;
|
|
||||||
// color.a = 0.6f;
|
|
||||||
// EditorGUI.DrawRect(lastRect, color);
|
|
||||||
// GUI.Box(lastRect, text);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public static void DrawUndeterminedConnectStatus(params GUILayoutOption[] options)
|
|
||||||
//{
|
|
||||||
// Init();
|
|
||||||
// if (options == null || options.Length <= 0)
|
|
||||||
// {
|
|
||||||
// options = _defaultParams;
|
|
||||||
// }
|
|
||||||
// GUILayout.Box(UNDETERMINED_CONNECTED, _grayStyle, options);
|
|
||||||
//}
|
|
||||||
public static void DrawComponents(entlong entity)
|
public static void DrawComponents(entlong entity)
|
||||||
{
|
{
|
||||||
if (entity.TryUnpack(out int entityID, out EcsWorld world))
|
if (entity.TryUnpack(out int entityID, out EcsWorld world))
|
||||||
@ -146,7 +94,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
public static void DrawComponents(int entityID, EcsWorld world)
|
public static void DrawComponents(int entityID, EcsWorld world)
|
||||||
{
|
{
|
||||||
var componentTypeIDs = world.GetComponentTypeIDs(entityID);
|
var componentTypeIDs = world.GetComponentTypeIDs(entityID);
|
||||||
|
|
||||||
GUILayout.BeginVertical(EcsEditor.GetStyle(Color.black, 0.2f));
|
GUILayout.BeginVertical(EcsEditor.GetStyle(Color.black, 0.2f));
|
||||||
|
GUILayout.Label("COMPONENTS");
|
||||||
|
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden);
|
||||||
|
|
||||||
foreach (var componentTypeID in componentTypeIDs)
|
foreach (var componentTypeID in componentTypeIDs)
|
||||||
{
|
{
|
||||||
var pool = world.GetPool(componentTypeID);
|
var pool = world.GetPool(componentTypeID);
|
||||||
@ -159,24 +111,25 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
private static readonly BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
private static readonly BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||||
private static void DrawComponent(int entityID, IEcsPool pool)
|
private static void DrawComponent(int entityID, IEcsPool pool)
|
||||||
{
|
{
|
||||||
object data = pool.GetRaw(entityID);
|
var meta = pool.ComponentType.ToMeta();
|
||||||
var meta = data.GetMeta();
|
if (meta.IsHidden == false || IsShowHidden)
|
||||||
|
|
||||||
Color panelColor = meta.Color.ToUnityColor();
|
|
||||||
GUILayout.BeginVertical(EcsEditor.GetStyle(panelColor, 0.22f));
|
|
||||||
EditorGUI.BeginChangeCheck();
|
|
||||||
|
|
||||||
Type componentType = pool.ComponentType;
|
|
||||||
ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType);
|
|
||||||
bool changed = DrawData(componentType, new GUIContent(meta.Name), expandMatrix, data, out object resultData);
|
|
||||||
if (changed)
|
|
||||||
{
|
{
|
||||||
pool.SetRaw(entityID, resultData);
|
object data = pool.GetRaw(entityID);
|
||||||
|
Color panelColor = meta.Color.ToUnityColor();
|
||||||
|
GUILayout.BeginVertical(EcsEditor.GetStyle(panelColor, 0.22f));
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
|
Type componentType = pool.ComponentType;
|
||||||
|
ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType);
|
||||||
|
bool changed = DrawData(componentType, new GUIContent(meta.Name), expandMatrix, data, out object resultData);
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
pool.SetRaw(entityID, resultData);
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.EndVertical();
|
||||||
|
GUILayout.Space(2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.EndVertical();
|
|
||||||
|
|
||||||
GUILayout.Space(2f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool DrawData(Type fieldType, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData)
|
private static bool DrawData(Type fieldType, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData)
|
||||||
|
Loading…
Reference in New Issue
Block a user