public void DestroyMe() { if (!isRoot && !destroyChildrenOnDestruction) { var p = FindParentElement(); TreeViewElement drg = null; foreach (Transform t in containerOfWholeTreeView) { if (t.GetComponent <TreeViewElement>().dragging) { drg = t.GetComponent <TreeViewElement>(); } } if (drg != null && drg.previousParent == childrenRoot) { drg.previousParent = p.childrenRoot; //onPreviousParentElementDestroyed?.Invoke(p); drg.positionInPreviousParent = p.childrenRoot.childCount - 1; } foreach (Transform t in childrenRoot) { t.SetParent(p.childrenRoot); } OnDestruction(); Destroy(gameObject); } }
public virtual void OnAttachTo(TreeViewElement newParent) { transform.SetParent(newParent.childrenRoot); if (newParent != null) { newParent.GetAssociatedTreeViewSelectable().Unhighlight(); } }
public virtual void OnDragHoverOn(TreeViewElement hoveredPotentialAttachElements, TreeViewElement previousHoveredPotentialAttachElements) { if (previousHoveredPotentialAttachElements != null) { previousHoveredPotentialAttachElements.GetAssociatedTreeViewSelectable().Unhighlight(); } if (hoveredPotentialAttachElements != null) { hoveredPotentialAttachElements.GetAssociatedTreeViewSelectable().Highlight(); } }
private TreeViewElement FindObjectToAttachTo_Aux(Transform childrenRoot, PointerEventData data, List <RaycastResult> raycastResults) { TreeViewElement res = null; foreach (Transform t in childrenRoot) { var tve = t.GetComponent <TreeViewElement>(); if (tve != null) { if (raycastResults.ConvertAll <GameObject>(_ => _.gameObject).Contains(tve.GetAssociatedTreeViewSelectable().GetGameObject())) { res = tve; break; } else if (tve.childrenRoot.childCount > 0) { res = FindObjectToAttachTo_Aux(tve.childrenRoot, data, raycastResults); } } } return(res); }
public void ActualOnDrag(PointerEventData data) { //dragging = true; if (!isRoot) { var _temp = FindObjectToAttachTo(data); if (_temp != _toattachto) { OnDragHoverOn(_temp, _toattachto); _toattachto = _temp; } Vector2 localPointerPosition; if (RectTransformUtility.ScreenPointToLocalPointInRectangle(DragAreaInternal, data.position, data.pressEventCamera, out localPointerPosition)) { Vector3 offsetToOriginal = localPointerPosition - originalLocalPointerPosition; DragObjectInternal.localPosition = originalPanelLocalPosition + offsetToOriginal; } ClampToArea(); } }