Hi,
I am trying to create a run time hierarchy using UI toolkit and TreeView but I can’t seem to find how to customize the drag and drop.
I want to parent the dragged label real GameObject to the dragged target real GameObject transform.
I am subscribing to
_treeView.handleDrop += OnHandleDrop;
And in OnHandleDrop i can get the target HierarchyItem like so:
private DragVisualMode OnHandleDrop(HandleDragAndDropArgs arg)
{
if(arg.dropPosition == DragAndDropPosition.OverItem)
{
var targetTransform = (arg.target as HierarchyItem)?.Go.transform;
}
return DragVisualMode.Move;
}
How can I get the source HierarchyItem (the one that is being dragged)?
public class HierarchyItem
{
public string Name { get; set; }
public GameObject Go { get; set; }
public int Depth { get; set; } // Determines the tree's indentation level
public List<HierarchyItem> Children { get; set; } = new List<HierarchyItem>();
}
I feel like I am missing something here, if anyone has any idea what I am doing wrong and how to get the source HierarchyItem I would love some help.