Skip to content

Commit 5495d00

Browse files
Fixed Drag and Drop behaviour
1 parent daa2e5d commit 5495d00

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Editor/Drawers/RawReferenceDrawer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public void OnGUI(Rect position)
5959
: new GUIContent(rawReferenceValue.GetType().Name, IconUtility.ScriptIcon);
6060

6161
CustomObjectDrawer.OnGUI(objectFieldRect, label, content);
62+
63+
HandleDragAndDrop(objectFieldRect);
64+
6265
if (rawReferenceValue == null)
6366
return;
6467

@@ -69,8 +72,6 @@ public void OnGUI(Rect position)
6972
RawReferenceProperty,
7073
new GUIContent(rawReferenceValue.GetType().Name),
7174
true);
72-
73-
HandleDragAndDrop(objectFieldRect);
7475
}
7576

7677
/// <inheritdoc />

Editor/Drawers/ReferenceDrawer.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,17 @@ private void OnItemSelected(ReferenceMode mode, object reference)
109109

110110
protected void HandleDragAndDrop(Rect position)
111111
{
112+
if (!position.Contains(Event.current.mousePosition))
113+
return;
114+
112115
if (Event.current.type == EventType.DragPerform)
113116
{
117+
HandleDragUpdated();
114118
HandleDragPerform();
115119
}
116120
else if (Event.current.type == EventType.DragUpdated)
117121
{
118-
HandleDragUpdated(position);
122+
HandleDragUpdated();
119123
}
120124
}
121125

@@ -134,11 +138,8 @@ private void SetDragAndDropMode(bool success, DragAndDropMode? successMode = nul
134138
}
135139
}
136140

137-
private void HandleDragUpdated(Rect position)
141+
private void HandleDragUpdated()
138142
{
139-
if (!position.Contains(Event.current.mousePosition))
140-
return;
141-
142143
if (DragAndDrop.objectReferences.Length > 1)
143144
{
144145
SetDragAndDropMode(false);

0 commit comments

Comments
 (0)