public void OnEndDrag(PointerEventData eventData) { if (!isDraggable && dragInitiated) { return; } List <RaycastResult> list = new List <RaycastResult>(); EventSystem.current.RaycastAll(eventData, list); foreach (var obj in list) { if (obj.gameObject.GetComponent <HeroPanel>() && obj.gameObject != gameObject) { dragManager.SetDragAction(true); SwapObjects(obj.gameObject); return; } } dragInitiated = false; transform.SetParent(ParentTransform); transform.position = SnapPosition; transform.SetAsFirstSibling(); }