mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
update
This commit is contained in:
parent
8bba0a01f8
commit
b13f7eaa4c
@ -120,8 +120,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
targets[i] = (EcsEntityConnect)this.targets[i];
|
||||
}
|
||||
DrawTop();
|
||||
|
||||
DrawEntityInfo(targets);
|
||||
|
||||
DrawTemplates();
|
||||
@ -129,52 +127,64 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
DrawButtons();
|
||||
DrawComponents(targets);
|
||||
}
|
||||
private void DrawTop()
|
||||
{
|
||||
var iterator = serializedObject.GetIterator();
|
||||
iterator.NextVisible(true);
|
||||
using (new EditorGUI.DisabledScope(true))
|
||||
{
|
||||
EditorGUILayout.PropertyField(iterator, true);
|
||||
}
|
||||
}
|
||||
|
||||
private const float line1 = 1f;
|
||||
private const float line2 = 2f;
|
||||
private void DrawEntityInfo(EcsEntityConnect[] targets)
|
||||
{
|
||||
float width = EditorGUIUtility.currentViewWidth;
|
||||
float height = EditorGUIUtility.singleLineHeight;
|
||||
Rect entityRect = GUILayoutUtility.GetRect(width, height + 3f);
|
||||
Rect entityRect = GUILayoutUtility.GetRect(width, height + line2 * 2f);
|
||||
|
||||
var (entityInfoRect, statusRect) = RectUtility.VerticalSliceBottom(entityRect, 3f);
|
||||
Color w = Color.gray;
|
||||
w.a = 0.6f;
|
||||
Color b = Color.black;
|
||||
b.a = 0.55f;
|
||||
EditorGUI.DrawRect(entityRect, w);
|
||||
|
||||
entityRect = RectUtility.AddPadding(entityRect, line1, line1, line2, 0);
|
||||
var (entityInfoRect, statusRect) = RectUtility.VerticalSliceBottom(entityRect, line2);
|
||||
|
||||
var (idRect, genWorldRect) = RectUtility.HorizontalSliceLerp(entityInfoRect, 0.5f);
|
||||
var (genRect, worldRect) = RectUtility.HorizontalSliceLerp(genWorldRect, 0.5f);
|
||||
|
||||
idRect = RectUtility.AddPadding(idRect, line1, 0);
|
||||
genRect = RectUtility.AddPadding(genRect, line1, 0);
|
||||
worldRect = RectUtility.AddPadding(worldRect, line1, 0);
|
||||
|
||||
EditorGUI.DrawRect(idRect, b);
|
||||
EditorGUI.DrawRect(genRect, b);
|
||||
EditorGUI.DrawRect(worldRect, b);
|
||||
|
||||
|
||||
bool isConnected = Target.Entity.TryUnpack(out int id, out short gen, out short world);
|
||||
|
||||
|
||||
GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
if (IsMultipleTargets == false && isConnected)
|
||||
{
|
||||
Color statusColor = EcsGUI.GreenColor;
|
||||
statusColor.a = 0.32f;
|
||||
statusColor.a = 0.4f;
|
||||
EditorGUI.DrawRect(statusRect, statusColor);
|
||||
EditorGUI.IntField(idRect, id);
|
||||
EditorGUI.IntField(genRect, gen);
|
||||
EditorGUI.IntField(worldRect, world);
|
||||
|
||||
EditorGUI.IntField(idRect, id, style);
|
||||
EditorGUI.IntField(genRect, gen, style);
|
||||
EditorGUI.IntField(worldRect, world, style);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (new EditorGUI.DisabledScope(true))
|
||||
{
|
||||
Color statusColor = IsMultipleTargets ? EcsGUI.GrayColor : EcsGUI.RedColor;
|
||||
statusColor.a = 0.32f;
|
||||
EditorGUI.DrawRect(statusRect, statusColor);
|
||||
EditorGUI.TextField(idRect, "Entity ID");
|
||||
EditorGUI.TextField(genRect, "Gen");
|
||||
EditorGUI.TextField(worldRect, "World ID");
|
||||
}
|
||||
Color statusColor = IsMultipleTargets ? new Color32(200, 200, 200, 255) : EcsGUI.RedColor;
|
||||
statusColor.a = 0.4f;
|
||||
EditorGUI.DrawRect(statusRect, statusColor);
|
||||
|
||||
Color dc = GUI.color;
|
||||
Color ndc = Color.white;
|
||||
ndc.a = 0.4f;
|
||||
GUI.color = ndc;
|
||||
GUI.Label(idRect, "Entity ID", EditorStyles.boldLabel);
|
||||
GUI.Label(genRect, "Generation", EditorStyles.boldLabel);
|
||||
GUI.Label(worldRect, "World ID", EditorStyles.boldLabel);
|
||||
GUI.color = dc;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,19 +138,18 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.Space(2f);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool DrawRuntimeData(Type fieldType, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData)
|
||||
{
|
||||
Type type = data.GetType();
|
||||
UnityEngine.Object uobj = data as UnityEngine.Object;
|
||||
bool isUnityObject = typeof(UnityEngine.Object).IsAssignableFrom(fieldType);
|
||||
ref bool isExpanded = ref expandMatrix.Down();
|
||||
bool changed = false;
|
||||
outData = data;
|
||||
|
||||
if (uobj == null && (type.IsGenericType || !type.IsSerializable))
|
||||
if (isUnityObject == false && (type.IsGenericType || !type.IsSerializable))
|
||||
{
|
||||
isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(isExpanded, label, EditorStyles.foldout);
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
@ -174,18 +173,32 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
WrapperBase w = uobj == null ? RefEditorWrapper.Take(data) : UnityObjEditorWrapper.Take(uobj);
|
||||
|
||||
w.IsExpanded = isExpanded;
|
||||
EditorGUILayout.PropertyField(w.Property, label, true);
|
||||
isExpanded = w.IsExpanded;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
if (isUnityObject)
|
||||
{
|
||||
w.SO.ApplyModifiedProperties();
|
||||
outData = w.Data;
|
||||
changed = true;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
UnityEngine.Object uobj = (UnityEngine.Object)data;
|
||||
uobj = EditorGUILayout.ObjectField(label, uobj, fieldType, true);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
outData = uobj;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
WrapperBase w = RefEditorWrapper.Take(data);
|
||||
|
||||
w.IsExpanded = isExpanded;
|
||||
EditorGUILayout.PropertyField(w.Property, label, true);
|
||||
isExpanded = w.IsExpanded;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
w.SO.ApplyModifiedProperties();
|
||||
outData = w.Data;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,15 +48,18 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
||||
|
||||
public static Rect AddPadding(Rect rect, float verticalHorizontal)
|
||||
{
|
||||
return AddPadding(rect, verticalHorizontal, verticalHorizontal);
|
||||
return AddPadding(rect, verticalHorizontal, verticalHorizontal, verticalHorizontal, verticalHorizontal);
|
||||
}
|
||||
|
||||
public static Rect AddPadding(Rect rect, float vertical, float horizontal)
|
||||
{
|
||||
rect.xMax -= horizontal;
|
||||
rect.xMin += horizontal;
|
||||
rect.yMax -= vertical;
|
||||
rect.yMin += vertical;
|
||||
return AddPadding(rect, vertical, vertical, horizontal, horizontal);
|
||||
}
|
||||
public static Rect AddPadding(Rect rect, float left, float right, float top, float bottom)
|
||||
{
|
||||
rect.xMin += left;
|
||||
rect.xMax -= right;
|
||||
rect.yMin += top;
|
||||
rect.yMax -= bottom;
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
|
@ -178,15 +178,21 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
#region Draw Component Block
|
||||
EditorGUI.DrawRect(propertyFullRect, alphaPanelColor);
|
||||
propertyRect = RectUtility.AddPadding(propertyRect, padding);
|
||||
bool isRemoveComponent = false;
|
||||
if (GUI.Button(removeButtonRect, "x"))
|
||||
{
|
||||
isRemoveComponent = true;
|
||||
}
|
||||
|
||||
if (isEmpty)
|
||||
{
|
||||
GUI.Label(propertyRect, label);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.PropertyField(propertyRect, componentProperty, label, true);
|
||||
EditorGUI.PropertyField(propertyFullRect, componentProperty, label, true);
|
||||
}
|
||||
if (GUI.Button(removeButtonRect, "x"))
|
||||
if (isRemoveComponent)
|
||||
{
|
||||
OnRemoveComponentAt(index);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user