public bool DragObjectEnd(object obj) { bool newDropPosition = false; DropArea drop; if (objectsDropArea.TryGetValue(obj, out drop)) { Event currentEvent = Event.current; if (Event.current != null) { Vector3 mouse = InputHelpers.MouseOnGUI(); if (InputHelpers.MouseDown(0) && CurrentDragObject.CurrentRect.Contains(mouse) && !somethingIsDraggingAlready) { somethingIsDraggingAlready = true; CurrentDragObject.IsDragging = true; CurrentDragObject.Ease = true; CurrentDragObject.t = 0; CurrentDragObject.EaseStartRect = CurrentDragObject.StartRect; CurrentDragObject.EaseEndRect = new Rect( mouse.x - CurrentDragObject.CurrentRect.width / 2f, mouse.y - CurrentDragObject.CurrentRect.height / 2f, CurrentDragObject.CurrentRect.width, CurrentDragObject.CurrentRect.height); } else if (InputHelpers.MouseMoved(0) && CurrentDragObject.IsDragging) { CurrentDragObject.IsDragging = true; CurrentDragObject.t = 0; CurrentDragObject.EaseStartRect = CurrentDragObject.CurrentRect; CurrentDragObject.EaseEndRect = new Rect( mouse.x - CurrentDragObject.CurrentRect.width / 2f, mouse.y - CurrentDragObject.CurrentRect.height / 2f, CurrentDragObject.CurrentRect.width, CurrentDragObject.CurrentRect.height); } else if (InputHelpers.MouseUp(0) && CurrentDragObject.IsDragging) { CurrentDragObject.t = 0; CurrentDragObject.IsDragging = false; somethingIsDraggingAlready = false; CurrentDragObject.Ease = true; DropArea selectedDropArea = null; foreach (DropArea dropArea in GetValidDropAreas(obj.GetType())) { if (dropArea.ContainsMouse() && dropArea.Object == null) { selectedDropArea = dropArea; newDropPosition = true; break; } } if (selectedDropArea != null && selectedDropArea.Object == null) { CurrentDragObject.EaseStartRect = CurrentDragObject.CurrentRect; CurrentDragObject.EaseEndRect = selectedDropArea.Rect; selectedDropArea.Object = obj; CurrentDragObject.DropArea.Object = null; objectsDropArea[obj] = selectedDropArea; CurrentDragObject.DropArea = selectedDropArea; CurrentDragObject.StartRect = CurrentDragObject.DropArea.Rect; } else { CurrentDragObject.EaseStartRect = CurrentDragObject.CurrentRect; CurrentDragObject.EaseEndRect = CurrentDragObject.StartRect; } } } easeDragObject(); dragObjectsInProgress.Pop(); } return(newDropPosition); }