• 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
0
Question by GalaxyNo8 · Sep 21, 2020 at 12:51 AM · drag-and-drop

DragAndDrop between two custom EditorWindow not working

Hi there,

The short version is I cannot start drag from the 1st custom EditorWindow and drop to the 2nd custom EditorWindow.

The longer one:

I have two EditorWindows, MyEditorWindowA and MyEditorWindowB.

I wrote some code with DragAndDrop in MyEditorWindowA and it works fine.

I start DragAndDrop.Start("xxx") in MyEditorWindowA and in MyEditorWindowA it can get DragAndDrop related events in the OnGUI function. Everything is good.

However, when I try to let MyEditorWindowB receive the drop result, I found that the 2nd CustomEditor won't get any event in the OnGUI function.

If I make MyEditorWindowB.wantsMouseEnterLeaveWindow true, it can get the Event.MouseLeaveWindow and Event.MouseEnterWindow events when I drag from MyEditorWindowA to MyEditorWindowB. There is not other events on it.

However, if I drag a file from the asset window to MyEditorWindowB, myEditorWindowB will get all the events related to the DragAndDrop.

So, what's wrong?

Thanks, Jeff

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Sep 21, 2020 at 01:03 AM

Your question was stuck in moderation all the time -.- I've quickly created a simple example and it worked just fine: DADTestWindowA. You can open multiple instances of this editor window. Each window has 3 draggable objects as well as one drop zone where you can drop any of our dragged objects. Note that this is a crude straight forward approach without any type checking.


Just to make sure it's not an issue with different window types, I made another seperate editor window DADTestWindowB which uses the same container class. I can drag any of the draggable objects from any of the opened windows to the drop zone of any of the other windows. Note currently I remove the object from the source container at the moment I drop the object on a valid target. This is currently a small issue since the source window will not be redrawn. So the object is still visible until the source window receives a repaint event. Of course you can handle this in your own logic accordingly. I started already implementing proper add and remove events for the container so the editor window can be redrawn when necessary. However I realised this is just a proof of concept and it does work as expected.


If you still have issues you need to share your code that doesn't work.

Comment
Add comment · Show 1 · 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
avatar image GalaxyNo8 · Sep 21, 2020 at 01:52 AM 0
Share

Hi Bunny, thanks. I finally found out that the reason why the 2nd window is not receiving drag related events is I didn't add this line: GUIUtility.hotControl = 0; After adding the code, it works fine.

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

136 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 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 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 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 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 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 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 avatar image avatar image avatar image

Related Questions

Drag and drop 3d game 1 Answer

Dragging an object in iOS (UnityScript) 3 Answers

how can i put just one child in a drag and drop container in ngui 1 Answer

How to create Arrows Between Two objects and Animate them 2 Answers

Why can't I assign transform.position to a Vector3 object? 3 Answers


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