Hi,
I’m trying to use the drag and drop functionality of the UnityEditor classes. I had a piece of code that worked fine yesterday, but today it does not work anymore. I haven’t changed ANYTHING:
if (Event.current.type == EventType.MouseDown && Event.current.button == 0) {
this.__draggedSection = sections*;*
- DragAndDrop.PrepareStartDrag();*
- DragAndDrop.StartDrag(“Dragging section”);*
- Event.current.Use();*
}
if (this.__draggedSection != null && Event.current.type == EventType.DragUpdated) { - DragAndDrop.visualMode = DragAndDropVisualMode.Copy;*
- Event.current.Use();*
}
if (this.__draggedSection != null && Event.current.type == EventType.DragPerform) {
- DragAndDrop.AcceptDrag();*
/if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && this.__draggedSection != sections) {
sections.ConnectFrom(this.__draggedSection);
this._draggedSection.ConnectTo(sections, sections.tiles[0]);
}/
* this.__draggedSection = null;*
* Event.current.Use();
}*
So today I opened Unity, opened the EditorWindow this was in and the drag and drop functionalities all were gone. Also some other weird stuff was going on. The MouseDown event was bugged; When I pressed the mouse, the MouseDown event was not triggered untill I released my mousebutton (a MouseUp event). Also whenever I was dragging, the DragUpdated event was never fired. When I removed the lines
DragAndDrop.PrepareStartDrag();
DragAndDrop.StartDrag(“Dragging section”);
The MouseDown event was behaving as normal again, but the drag functionality did not work anymore. I’m aware that I can just use regular mouse events, but I’d like to see this DragAndDrop class work properly (also because I can just easily change the cursor while dragging). Anybody encoutered this before? I work on Windows 7 Profesional, Unity 3.5.
Thanks!_