Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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 AVividLight · Feb 01, 2012 at 05:27 AM · c#drag and drop

Is it possible to drag a file from the desktop into a desktop application

Hey guys,

I'm off to a very bad start with my new project, as it all revolves around drag and drop; which I can't figure out. Anyway, I have looked around on Google, but can't find anything that is of much help to me. I have, however, found a few things that give me a basic idea (MSDN, CodeProject, CodeProject2), although they all use the System.Windows namespace, which Unity doesn't seem to like. Maybe I am missing something, but I can't figure this out.

If it helps, my goal is to make a simple application, with a drag and drop window (one for an image, one for a ".txt" file), that will encode the text from the .txt file and hide it in the structure of the image. So far, all I have done is searched Google for some help with Drag and Drop windows, so any help is very valuable to me!

I really appreciate you taking the time to read this, and keep in mind, every bit of help is useful at this point.

-Thanks for your time, guys ∆ Gibson

Comment
Add comment · Show 2
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 chilton · Mar 07, 2019 at 01:45 PM 0
Share

I had the same question. Looks like there's a Windows answer, but not $$anonymous$$ac. So I have to do a little $$anonymous$$ac program$$anonymous$$g work. If I get it working, I'll report back with a link.

avatar image jiandanM · Nov 08, 2019 at 09:20 AM 0
Share

I had the same question.How does it work on a $$anonymous$$AC,

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Feb 02, 2012 at 09:19 PM

This has already been asked here:

http://answers.unity3d.com/questions/189577/drag-and-drop-files-into-unity3d-window.html

edit
I'm a bit confused why you want to do such an app as Unity application? That seems to be much easier when you just use C# / C++ and the windows API (in case you want to target windows which can't be determined from your question).

As i said in the comment of the question above it could be possible to kind of hack into the message queue of your application window, but that's not a nice solution. I guess it would be easier to create a native code plugin which creates another window which will accept drag&drop opperations and hand over this information to Unity.

Of course this is not an optimal solution, but Unity isn't designed for office-application development. Well Unity could add such a feature in the future, but it's really something that almost nobody needs.

Well it would be nice to have something like that in the webplayer together with a secure interface to the dropped data (only read access). This would make Unity more valueable for webtool-development, but as already said there is just a minority of people that would need something like that.

Comment
Add comment · Show 8 · 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 AVividLight · Feb 02, 2012 at 09:21 PM 0
Share

Thanks, Bunny83, you have just saved me a lot of time!

avatar image Bunny83 · Feb 02, 2012 at 09:50 PM 1
Share

I've just posted a feature request here ;)

avatar image Bunny83 · Feb 10, 2018 at 06:07 AM 0
Share

I've created a class which is able to intercept W$$anonymous$$_DROPFILES messages in Unity standalone builds. Have a look over here (github)

avatar image meat5000 ♦ Bunny83 · Feb 10, 2018 at 06:48 PM 0
Share

Is it a Unity question? :D

avatar image Bunny83 meat5000 ♦ · Feb 11, 2018 at 12:49 PM 0
Share

Yes, it is ^^. The main issue is that Unity is closed source and the main message pump of the application belongs to Unity's native code we don't have access to. So when your Unity application wants to react to dropped files (on windows builds) it has to react to the W$$anonymous$$_DROPFILES message that is send to the window message queue. $$anonymous$$y solution is to install a hook to intercept that message and retrieve the filenames of the dropped files.


A long time ago i've actually created a feature request to add drag and drop support to Unity directly. While my solution works for Windows you would need a different approach for mac or linux builds. That's why it would be nice to have some generic API from the Unity player. Enabling drag and drop in windows for a window is literally just a single call to DragAcceptFiles. Including the handling code for W$$anonymous$$_DROPFILES would be much simpler when done in native code.


The webplayer part is of course obsolete now ^^. The funny thing is that dragging files to WebGL builds can be easier worked around since you can directly handle those things in javascript in the browser.

avatar image chilton Bunny83 · Mar 07, 2019 at 01:47 PM 0
Share

Oh hells yes! Thank you so much for doing this!!

avatar image Bas-Smit Bunny83 · Apr 10, 2019 at 02:24 PM 0
Share

Should this still be working? Using 2019.1 on Windows 10. I get the (/) icon when trying to drag, anything I need to set up other than adding the example?

avatar image chilton · Mar 07, 2019 at 01:47 PM 0
Share

"I'm a bit confused why you want to do such an app as Unity application?"

Because Unity is not just used just for games.

I mean, you might only use it for games, but there are lots of people using it for things other than games, too. There's a TON of application space out there that Unity serves, and being able to interact with the file system easier makes it a much more palatable solution for everyone.

avatar image
0

Answer by flamy · Feb 02, 2012 at 05:11 PM

you can check it by dragging the corresponding dll of class you want want to use inside unity!! most of the system.*.dlls worked for me !! After draggin it into unity, it works like any other class!

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.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Modular building system. 0 Answers

Drag and Drop on RTS camera 1 Answer

Drag multiple gameobjects ? 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