mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 17:34:34 +08:00
Update EntlongDrawer.cs
This commit is contained in:
parent
a8f08f2137
commit
fdbdb94b0c
@ -22,11 +22,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
int controlID = GUIUtility.GetControlID(s_ObjectFieldHash, FocusType.Keyboard, position);
|
int controlID = GUIUtility.GetControlID(s_ObjectFieldHash, FocusType.Keyboard, position);
|
||||||
|
|
||||||
bool containsMouse = dropRect.Contains(Event.current.mousePosition);
|
bool containsMouse = dropRect.Contains(Event.current.mousePosition);
|
||||||
bool dragPerform = eventType == EventType.DragPerform;
|
|
||||||
|
|
||||||
if(containsMouse && eventType == EventType.Repaint)
|
if(containsMouse && eventType == EventType.Repaint && DragAndDrop.activeControlID == controlID)
|
||||||
{
|
{
|
||||||
EditorStyles.selectionRect.Draw(dropRect.AddPadding(-1), UnityEditorUtility.GetLabelTemp(), controlID, DragAndDrop.activeControlID == controlID, position.Contains(Event.current.mousePosition));
|
EditorStyles.selectionRect.Draw(dropRect.AddPadding(-1), GUIContent.none, controlID, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -85,75 +84,77 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
|
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dragPerform)
|
if (eventType == EventType.DragPerform || eventType == EventType.DragUpdated)
|
||||||
{
|
{
|
||||||
entlong ent = default;
|
if (eventType == EventType.DragPerform)
|
||||||
bool isValide = false;
|
|
||||||
var dragged = DragAndDrop.objectReferences[0];
|
|
||||||
if (dragged is GameObject go)
|
|
||||||
{
|
{
|
||||||
if (go.TryGetComponent(out EcsEntityConnect connect))
|
entlong ent = default;
|
||||||
|
bool isValide = false;
|
||||||
|
var dragged = DragAndDrop.objectReferences[0];
|
||||||
|
if (dragged is GameObject go)
|
||||||
{
|
{
|
||||||
ent = connect.Entity;
|
if (go.TryGetComponent(out EcsEntityConnect connect))
|
||||||
isValide = true;
|
|
||||||
}
|
|
||||||
else if (go.TryGetComponent(out EntityMonitor monitor))
|
|
||||||
{
|
|
||||||
ent = monitor.Entity;
|
|
||||||
isValide = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var beh in go.GetComponents<MonoBehaviour>())
|
|
||||||
{
|
{
|
||||||
if(TryFindEntlong(beh, out ent))
|
ent = connect.Entity;
|
||||||
|
isValide = true;
|
||||||
|
}
|
||||||
|
else if (go.TryGetComponent(out EntityMonitor monitor))
|
||||||
|
{
|
||||||
|
ent = monitor.Entity;
|
||||||
|
isValide = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var beh in go.GetComponents<MonoBehaviour>())
|
||||||
{
|
{
|
||||||
isValide = true;
|
if (TryFindEntlong(beh, out ent))
|
||||||
break;
|
{
|
||||||
|
isValide = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dragged is EcsEntityConnect connect)
|
||||||
|
{
|
||||||
|
ent = connect.Entity;
|
||||||
|
isValide = true;
|
||||||
|
}
|
||||||
|
else if (dragged is EntityMonitor monitor)
|
||||||
|
{
|
||||||
|
ent = monitor.Entity;
|
||||||
|
isValide = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (TryFindEntlong(dragged, out ent))
|
||||||
|
{
|
||||||
|
isValide = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (isValide)
|
||||||
|
{
|
||||||
|
long entityLong = *(long*)&ent;
|
||||||
|
fulleProperty.longValue = entityLong;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EcsGUI.Changed = true;
|
||||||
|
DragAndDrop.AcceptDrag();
|
||||||
|
DragAndDrop.activeControlID = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (dragged is EcsEntityConnect connect)
|
DragAndDrop.activeControlID = controlID;
|
||||||
{
|
|
||||||
ent = connect.Entity;
|
|
||||||
isValide = true;
|
|
||||||
}
|
|
||||||
else if (dragged is EntityMonitor monitor)
|
|
||||||
{
|
|
||||||
ent = monitor.Entity;
|
|
||||||
isValide = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (TryFindEntlong(dragged, out ent))
|
|
||||||
{
|
|
||||||
isValide = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isValide)
|
|
||||||
{
|
|
||||||
long entityLong = *(long*)&ent;
|
|
||||||
fulleProperty.longValue = entityLong;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
EcsGUI.Changed = true;
|
|
||||||
DragAndDrop.AcceptDrag();
|
|
||||||
DragAndDrop.activeControlID = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DragAndDrop.activeControlID = controlID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Event.current.Use();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryFindEntlong(Object uniObj, out entlong ent)
|
private bool TryFindEntlong(Object uniObj, out entlong ent)
|
||||||
|
Loading…
Reference in New Issue
Block a user