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];
|
targets[i] = (EcsEntityConnect)this.targets[i];
|
||||||
}
|
}
|
||||||
DrawTop();
|
|
||||||
|
|
||||||
DrawEntityInfo(targets);
|
DrawEntityInfo(targets);
|
||||||
|
|
||||||
DrawTemplates();
|
DrawTemplates();
|
||||||
@ -129,52 +127,64 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
DrawButtons();
|
DrawButtons();
|
||||||
DrawComponents(targets);
|
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)
|
private void DrawEntityInfo(EcsEntityConnect[] targets)
|
||||||
{
|
{
|
||||||
float width = EditorGUIUtility.currentViewWidth;
|
float width = EditorGUIUtility.currentViewWidth;
|
||||||
float height = EditorGUIUtility.singleLineHeight;
|
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 (idRect, genWorldRect) = RectUtility.HorizontalSliceLerp(entityInfoRect, 0.5f);
|
||||||
var (genRect, worldRect) = RectUtility.HorizontalSliceLerp(genWorldRect, 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);
|
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)
|
if (IsMultipleTargets == false && isConnected)
|
||||||
{
|
{
|
||||||
Color statusColor = EcsGUI.GreenColor;
|
Color statusColor = EcsGUI.GreenColor;
|
||||||
statusColor.a = 0.32f;
|
statusColor.a = 0.4f;
|
||||||
EditorGUI.DrawRect(statusRect, statusColor);
|
EditorGUI.DrawRect(statusRect, statusColor);
|
||||||
EditorGUI.IntField(idRect, id);
|
|
||||||
EditorGUI.IntField(genRect, gen);
|
EditorGUI.IntField(idRect, id, style);
|
||||||
EditorGUI.IntField(worldRect, world);
|
EditorGUI.IntField(genRect, gen, style);
|
||||||
|
EditorGUI.IntField(worldRect, world, style);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (new EditorGUI.DisabledScope(true))
|
Color statusColor = IsMultipleTargets ? new Color32(200, 200, 200, 255) : EcsGUI.RedColor;
|
||||||
{
|
statusColor.a = 0.4f;
|
||||||
Color statusColor = IsMultipleTargets ? EcsGUI.GrayColor : EcsGUI.RedColor;
|
EditorGUI.DrawRect(statusRect, statusColor);
|
||||||
statusColor.a = 0.32f;
|
|
||||||
EditorGUI.DrawRect(statusRect, statusColor);
|
Color dc = GUI.color;
|
||||||
EditorGUI.TextField(idRect, "Entity ID");
|
Color ndc = Color.white;
|
||||||
EditorGUI.TextField(genRect, "Gen");
|
ndc.a = 0.4f;
|
||||||
EditorGUI.TextField(worldRect, "World ID");
|
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.EndVertical();
|
||||||
GUILayout.Space(2f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool DrawRuntimeData(Type fieldType, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData)
|
private static bool DrawRuntimeData(Type fieldType, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData)
|
||||||
{
|
{
|
||||||
Type type = data.GetType();
|
Type type = data.GetType();
|
||||||
UnityEngine.Object uobj = data as UnityEngine.Object;
|
bool isUnityObject = typeof(UnityEngine.Object).IsAssignableFrom(fieldType);
|
||||||
ref bool isExpanded = ref expandMatrix.Down();
|
ref bool isExpanded = ref expandMatrix.Down();
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
outData = data;
|
outData = data;
|
||||||
|
|
||||||
if (uobj == null && (type.IsGenericType || !type.IsSerializable))
|
if (isUnityObject == false && (type.IsGenericType || !type.IsSerializable))
|
||||||
{
|
{
|
||||||
isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(isExpanded, label, EditorStyles.foldout);
|
isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(isExpanded, label, EditorStyles.foldout);
|
||||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||||
@ -174,18 +173,32 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EditorGUI.BeginChangeCheck();
|
if (isUnityObject)
|
||||||
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())
|
|
||||||
{
|
{
|
||||||
w.SO.ApplyModifiedProperties();
|
EditorGUI.BeginChangeCheck();
|
||||||
outData = w.Data;
|
UnityEngine.Object uobj = (UnityEngine.Object)data;
|
||||||
changed = true;
|
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)
|
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)
|
public static Rect AddPadding(Rect rect, float vertical, float horizontal)
|
||||||
{
|
{
|
||||||
rect.xMax -= horizontal;
|
return AddPadding(rect, vertical, vertical, horizontal, horizontal);
|
||||||
rect.xMin += horizontal;
|
}
|
||||||
rect.yMax -= vertical;
|
public static Rect AddPadding(Rect rect, float left, float right, float top, float bottom)
|
||||||
rect.yMin += vertical;
|
{
|
||||||
|
rect.xMin += left;
|
||||||
|
rect.xMax -= right;
|
||||||
|
rect.yMin += top;
|
||||||
|
rect.yMax -= bottom;
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,15 +178,21 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
#region Draw Component Block
|
#region Draw Component Block
|
||||||
EditorGUI.DrawRect(propertyFullRect, alphaPanelColor);
|
EditorGUI.DrawRect(propertyFullRect, alphaPanelColor);
|
||||||
propertyRect = RectUtility.AddPadding(propertyRect, padding);
|
propertyRect = RectUtility.AddPadding(propertyRect, padding);
|
||||||
|
bool isRemoveComponent = false;
|
||||||
|
if (GUI.Button(removeButtonRect, "x"))
|
||||||
|
{
|
||||||
|
isRemoveComponent = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (isEmpty)
|
if (isEmpty)
|
||||||
{
|
{
|
||||||
GUI.Label(propertyRect, label);
|
GUI.Label(propertyRect, label);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EditorGUI.PropertyField(propertyRect, componentProperty, label, true);
|
EditorGUI.PropertyField(propertyFullRect, componentProperty, label, true);
|
||||||
}
|
}
|
||||||
if (GUI.Button(removeButtonRect, "x"))
|
if (isRemoveComponent)
|
||||||
{
|
{
|
||||||
OnRemoveComponentAt(index);
|
OnRemoveComponentAt(index);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user