Skip to content

Commit 2199452

Browse files
Merge branch '#22-Fix-DragAndDrop-ReferenceDrawer' into Merging
2 parents e3ecc45 + 5495d00 commit 2199452

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
@@ -72,6 +72,9 @@ public void OnGUI(Rect position)
7272
: new GUIContent(rawReferenceValue.GetType().Name, IconUtility.ScriptIcon);
7373

7474
CustomObjectDrawer.OnGUI(objectFieldRect, label, content);
75+
76+
HandleDragAndDrop(objectFieldRect);
77+
7578
if (rawReferenceValue == null)
7679
return;
7780

@@ -83,8 +86,6 @@ public void OnGUI(Rect position)
8386
new GUIContent(rawReferenceValue.GetType().Name),
8487
true);
8588

86-
HandleDragAndDrop(objectFieldRect);
87-
8889
previousPropertyPath = Property.propertyPath;
8990
}
9091

Editor/Drawers/ReferenceDrawer.cs

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

148148
protected void HandleDragAndDrop(Rect position)
149149
{
150+
if (!position.Contains(Event.current.mousePosition))
151+
return;
152+
150153
if (Event.current.type == EventType.DragPerform)
151154
{
155+
HandleDragUpdated();
152156
HandleDragPerform();
153157
}
154158
else if (Event.current.type == EventType.DragUpdated)
155159
{
156-
HandleDragUpdated(position);
160+
HandleDragUpdated();
157161
}
158162
}
159163

@@ -172,11 +176,8 @@ private void SetDragAndDropMode(bool success, DragAndDropMode? successMode = nul
172176
}
173177
}
174178

175-
private void HandleDragUpdated(Rect position)
179+
private void HandleDragUpdated()
176180
{
177-
if (!position.Contains(Event.current.mousePosition))
178-
return;
179-
180181
if (DragAndDrop.objectReferences.Length > 1)
181182
{
182183
SetDragAndDropMode(false);

0 commit comments

Comments
 (0)