mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
update runtime component display
This commit is contained in:
parent
7b2f9f5093
commit
60723a67f6
@ -51,6 +51,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
private static readonly BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||
|
||||
internal readonly static Color GrayColor = new Color32(100, 100, 100, 255);
|
||||
internal readonly static Color GreenColor = new Color32(75, 255, 0, 255);
|
||||
@ -61,6 +62,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
|
||||
public static float EntityBarHeight => EditorGUIUtility.singleLineHeight + 3f;
|
||||
|
||||
#region Properties
|
||||
private static ComponentColorMode AutoColorMode
|
||||
{
|
||||
get { return SettingsPrefs.instance.ComponentColorMode; }
|
||||
set { SettingsPrefs.instance.ComponentColorMode = value; }
|
||||
}
|
||||
private static bool IsShowHidden
|
||||
{
|
||||
get { return SettingsPrefs.instance.IsShowHidden; }
|
||||
@ -71,7 +78,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
get { return SettingsPrefs.instance.IsShowRuntimeComponents; }
|
||||
set { SettingsPrefs.instance.IsShowRuntimeComponents = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region enums
|
||||
public enum AddClearComponentButton : byte
|
||||
{
|
||||
None = 0,
|
||||
@ -85,7 +94,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
Alive = 1 << 0,
|
||||
Undefined = 1 << 1,
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region HitTest
|
||||
internal static bool HitTest(Rect rect)
|
||||
{
|
||||
return HitTest(rect, Event.current.mousePosition);
|
||||
@ -103,7 +114,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
return point.x >= rect.xMin - (float)offset && point.x < rect.xMax + (float)offset && point.y >= rect.yMin - (float)offset && point.y < rect.yMax + (float)offset;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region small elems
|
||||
public static void DrawIcon(Rect position, Texture icon, float iconPadding, string description)
|
||||
{
|
||||
GUI.Label(position, UnityEditorUtility.GetLabel(string.Empty, description));
|
||||
@ -164,8 +177,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
return IconButton(position, Icons.Instance.CloseIcon, 0f, "Delete Entity");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region entity bar
|
||||
public static void EntityBarForAlive(Rect position, EntityStatus status, int id, short gen, short world)
|
||||
{
|
||||
EntityBar(position, status != EntityStatus.Alive, status, id, gen, world);
|
||||
@ -243,6 +257,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static bool AddComponentButtons(Rect position)
|
||||
{
|
||||
@ -281,6 +296,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
EditorGUILayout.IntField("Leaked Entites", leakedEntitesCount, EditorStyles.boldLabel);
|
||||
}
|
||||
}
|
||||
|
||||
#region entity bar
|
||||
public static void EntityBarForAlive(EntityStatus status, int id, short gen, short world)
|
||||
{
|
||||
float width = EditorGUIUtility.currentViewWidth;
|
||||
@ -305,6 +322,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
float height = EntityBarHeight;
|
||||
EcsGUI.EntityBar(GUILayoutUtility.GetRect(width, height));
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static bool AddComponentButtons()
|
||||
{
|
||||
@ -344,24 +362,47 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
GUILayout.Box("", UnityEditorUtility.GetStyle(GUI.color, 0.16f), GUILayout.ExpandWidth(true));
|
||||
IsShowHidden = EditorGUI.Toggle(GUILayoutUtility.GetLastRect(), "Show Hidden", IsShowHidden);
|
||||
|
||||
int i = 0;
|
||||
foreach (var componentTypeID in componentTypeIDs)
|
||||
{
|
||||
var pool = world.GetPoolInstance(componentTypeID);
|
||||
{
|
||||
DrawRuntimeComponent(entityID, pool);
|
||||
DrawRuntimeComponent(componentTypeIDs.Length, i++, entityID, pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
private static readonly BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||
private static void DrawRuntimeComponent(int entityID, IEcsPool pool)
|
||||
private static void DrawRuntimeComponent(int total, int index, int entityID, IEcsPool pool)
|
||||
{
|
||||
var meta = pool.ComponentType.ToMeta();
|
||||
if (meta.IsHidden == false || IsShowHidden)
|
||||
{
|
||||
object data = pool.GetRaw(entityID);
|
||||
Color panelColor = meta.Color.ToUnityColor().Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
|
||||
//Color panelColor = meta.Color.ToUnityColor().Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
|
||||
|
||||
Color panelColor;
|
||||
if (meta.IsCustomColor)
|
||||
{
|
||||
panelColor = meta.Color.ToUnityColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (AutoColorMode)
|
||||
{
|
||||
case ComponentColorMode.Auto:
|
||||
panelColor = meta.Color.ToUnityColor().Desaturate(0.48f) / 1.18f; //.Desaturate(0.48f) / 1.18f;
|
||||
break;
|
||||
case ComponentColorMode.Rainbow:
|
||||
Color hsv = Color.HSVToRGB(1f / (Mathf.Max(total, EscEditorConsts.AUTO_COLOR_RAINBOW_MIN_RANGE)) * index, 1, 1);
|
||||
panelColor = hsv.Desaturate(0.48f) / 1.18f;
|
||||
break;
|
||||
default:
|
||||
panelColor = index % 2 == 0 ? new Color(0.40f, 0.40f, 0.40f) : new Color(0.54f, 0.54f, 0.54f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
panelColor = panelColor.Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
|
||||
|
||||
float padding = EditorGUIUtility.standardVerticalSpacing;
|
||||
Rect removeButtonRect = GUILayoutUtility.GetLastRect();
|
||||
|
Loading…
Reference in New Issue
Block a user