mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 10:04:36 +08:00
refactoring
This commit is contained in:
parent
e2286a877e
commit
b25c752c7f
@ -1079,9 +1079,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
DrawRuntimeComponents(entityID, world, isWithFoldout);
|
||||
}
|
||||
}
|
||||
|
||||
[ThreadStatic]
|
||||
private static List<IEcsPool> _componentPoolsBuffer;
|
||||
public static void DrawRuntimeComponents(int entityID, EcsWorld world, bool isWithFoldout = true)
|
||||
{
|
||||
var componentTypeIDs = world.GetComponentTypeIDsFor(entityID);
|
||||
|
||||
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f)))
|
||||
{
|
||||
@ -1100,26 +1102,27 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
GUILayout.Box("", UnityEditorUtility.GetStyle(GUI.color, 0.16f), GUILayout.ExpandWidth(true));
|
||||
IsShowHidden = EditorGUI.Toggle(GUILayoutUtility.GetLastRect(), "Show Hidden", IsShowHidden);
|
||||
|
||||
if (_componentPoolsBuffer == null)
|
||||
{
|
||||
_componentPoolsBuffer = new List<IEcsPool>(64);
|
||||
}
|
||||
world.GetComponentPoolsFor(entityID, _componentPoolsBuffer);
|
||||
int i = 0;
|
||||
foreach (var componentTypeID in componentTypeIDs)
|
||||
int iMax = _componentPoolsBuffer.Count;
|
||||
foreach (var componentPool in _componentPoolsBuffer)
|
||||
{
|
||||
var pool = world.FindPoolInstance(componentTypeID);
|
||||
{
|
||||
DrawRuntimeComponent(componentTypeIDs.Length, i++, entityID, pool);
|
||||
DrawRuntimeComponent(entityID, componentPool, iMax, i++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void DrawRuntimeComponent(int total, int index, int entityID, IEcsPool pool)
|
||||
private static void DrawRuntimeComponent(int entityID, IEcsPool pool, int total, int index)
|
||||
{
|
||||
var meta = pool.ComponentType.ToMeta();
|
||||
if (meta.IsHidden == false || IsShowHidden)
|
||||
{
|
||||
object data = pool.GetRaw(entityID);
|
||||
|
||||
Color panelColor = SelectPanelColor(meta, index, total).Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
|
||||
|
||||
Type componentType = pool.ComponentType;
|
||||
ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType);
|
||||
|
||||
@ -1136,7 +1139,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
isExpanded = !isExpanded;
|
||||
}
|
||||
|
||||
GUILayout.BeginVertical(UnityEditorUtility.GetStyle(panelColor, EscEditorConsts.COMPONENT_DRAWER_ALPHA));
|
||||
Color panelColor = SelectPanelColor(meta, index, total).Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE).SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA);
|
||||
GUILayout.BeginVertical(UnityEditorUtility.GetStyle(panelColor));
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
//Close button
|
||||
@ -1192,7 +1196,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
|
||||
if (isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
using (UpIndentLevel())
|
||||
{
|
||||
foreach (var field in type.GetFields(fieldFlags))
|
||||
{
|
||||
GUIContent subLabel = UnityEditorUtility.GetLabel(UnityEditorUtility.TransformFieldName(field.Name));
|
||||
@ -1203,7 +1208,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1226,6 +1231,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
uobj = go.GetComponent(fieldType);
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
outData = uobj;
|
||||
|
Loading…
Reference in New Issue
Block a user