Search Unity

TreeView.HandleDragAndDrop fires twice

Discussion in 'Editor & General Support' started by Eldoir, Feb 1, 2019.

  1. Eldoir

    Eldoir

    Joined:
    Feb 27, 2015
    Posts:
    60
    Hello,

    I don't know why this happens but it's a huge pain.
    I've overriden TreeView.HandleDragAndDrop:

    Code (CSharp):
    1. protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
    2.     {
    3.         if (args.performDrop)
    4.         {
    5.             if (args.dragAndDropPosition == DragAndDropPosition.UponItem)
    6.                 Debug.Log("Twice??");
    7.             else
    8.                 Debug.Log("Once");
    9.         }
    10.  
    11.         // code...
    12.     }
    In this method, I want to do an AssetDatabase.MoveAsset.
    When I drag my file upon a folder and release the mouse button, the method seems to fire twice?
    When it does, obviously my code raises an error because I already moved the asset the first time.
    Is this really a wanted behaviour?