Drag and drop files into unity3d window?

If I have a Unity app running in a browser or just in a window natively on a machine is it possible ot get it to accept files I drag and drop into it? Like I grab a jpeg and drag it over the unity window and just drop it, could unity grab that and read it in (possibly also load it up froma file directory).

Just trying to see if I can make something like a photogallery using unity…

I’ve just created a drag and drop solution for windows standalone builds. See the project on github. It doesn’t require a native code plugin. All is done from managed code and only uses several win API functions through P/Invoke. It installs a GetMessage hook for the main thread which is able to intercept the WM_DROPFILES message that the application receives upon dropping files onto your application.

Some important notes:

  • Make sure the instance of the “UnityDragAndDropHook” does stay in memory. Always call UninstallHook before you dismiss the instance.
  • Do not create several instances and do not install the hook several times.
  • The returned file paths are just returned as they have been passed by the OS. Note that “link files”(*.lnk) are not resolved.
  • Keep in mind that a path doesn’t need to represent a file but could also be a folder.

Am pretty sure that Unity applications do not respond to the WM_DROPFILES windows message, so, no, I don’t think you can do that.