• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by jeev · Aug 30, 2013 at 11:17 AM · draganddrop

DragAndDrop class bugged?

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[i];
     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[i]) {
         sections[i].ConnectFrom(this.__draggedSection);
         this.__draggedSection.ConnectTo(sections[i], sections[i].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!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image LightStriker · Sep 27, 2013 at 03:47 PM 0
Share

I know it's old, but I have the same issue with Unity 4.1. This morning, all my drag and drop decide to stop working. If I comment StartDrag(), everything goes back to normal - expect the drag and drop behavior.

All the Event stop firing as long as StartDrag is around. Worst, the whole UI of Unity appear to be frozen in time. Other windows just stop refreshing.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by s0ulboy05 · May 22, 2014 at 10:33 AM

Before calling StartDrag (and after PrepareStartDrag) try assigning something to the field DragAndDrop.objectReferences. For me it worked this code:


    DragAndDrop.objectReferences = new UnityEngine.Object[0];

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

DragAndDrop EditorGUILayout.Box ? 1 Answer

How to tell if DragAndDrop has been cancelled or completed. 0 Answers

Drag and Drop menu and Save load game. 0 Answers

How to swap textures? 1 Answer

Drag And Drop with Perspective Camera 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges