Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

how to get the drag&drop url in unity?

Discussion in 'Editor & General Support' started by azuretttc, May 20, 2009.

  1. azuretttc

    azuretttc

    Joined:
    May 8, 2009
    Posts:
    75
    Is it possible to get the drap&drop url in unity? Similar to it in windows, C++, we can use IDropTarget interface to get the dragged URL, is it possible to get the dragged URL in unity? also the web player version?
     
  2. azuretttc

    azuretttc

    Joined:
    May 8, 2009
    Posts:
    75
    I'm trying this, attaching the following script to an empty gameobject, but it doesn't work, can anybody help me?

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Windows.Forms;
    4.  
    5. public class Dropper: MonoBehaviour, IDropTarget
    6. {
    7.  
    8.     // Use this for initialization
    9.     void Start () {
    10.    
    11.     }
    12.    
    13.     // Update is called once per frame
    14.     void Update () {
    15.    
    16.     }
    17.    
    18.     public void OnDragDrop(System.Windows.Forms.DragEventArgs e)
    19.     {
    20.         Debug.Log("dropped");
    21.     }  
    22.    
    23.     public void OnDragEnter(System.Windows.Forms.DragEventArgs e)
    24.     {
    25.                 Debug.Log("dropping");
    26.     }
    27.    
    28.     public void OnDragLeave(System.EventArgs e)
    29.     {
    30.                         Debug.Log("dropping");
    31.     }  
    32.  
    33.     public void OnDragOver(System.Windows.Forms.DragEventArgs e)
    34.     {
    35.                         Debug.Log("dropping");
    36.     }
    37.    
    38. }
     
  3. azuretttc

    azuretttc

    Joined:
    May 8, 2009
    Posts:
    75
    any solutions on that?
     
  4. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    No, not in the web player.


    Tip: learn to use code tags please, it makes code included in your posts much easier to read. Look for the "Code" button at the top of the form when making your posts. If you use that, or manually wrap sample code chunks with [ code ] and [ /code ] (without the spaces) it looks much nicer.

    I've edited your post to use them, please go into edit mode on that yourself to see what I did as an example.
     
  5. Tyen_

    Tyen_

    Joined:
    Jun 4, 2014
    Posts:
    12
    Six year old thread revive!

    I am in the middle of looking into this now and am using Unity 5.2.1f1 and Windows.

    I have been through setting DragAcceptFiles
    http://stackoverflow.com/questions/...-whole-window-titlebar-and-window-borders-inc

    ..and setting SetWinEventHook with the various DragDrop related EventConstants.

    IDropTarget led me to this thread, while looking at the RegisterDragDrop.

    But I've had no luck.
    The closest I came was with the DragAcceptFiles, where it caused the cursor to change icon when dragging a file over the Unity Editor or Built application window.

    Anyone out there have a solid way to catch dropped files?
     
  6. Tyen_

    Tyen_

    Joined:
    Jun 4, 2014
    Posts:
    12
    Anyone?
     
  7. Sphax84

    Sphax84

    Joined:
    Jun 23, 2015
    Posts:
    35
    1 year old later, still nothing?

    Sorry to revive such old thread again but I can't find any solution yet and still searching.
     
  8. JeffHardddyyy

    JeffHardddyyy

    Joined:
    Dec 6, 2015
    Posts:
    23
    It was posted in 2009 too.
     
  9. geekdrums

    geekdrums

    Joined:
    Nov 23, 2013
    Posts:
    1
    This helps a lot.

    Unity(x86/x64)でWindowsメッセージを受け取る方法 - Qiita http://qiita.com/DandyMania/items/d1404c313f67576d395f

    and I succeeded to implement drag and drop itself, but application seems to be not stable.
    so I ended up stop using this...