private void GetDraggable() { var pointerData = new PointerEventData(EvSystem); pointerData.position = transform.position; EvSystem.RaycastAll(pointerData, raycastResults); foreach (var result in raycastResults) { dragHandler = result.gameObject.GetComponentInParent <IDragHandler>(); if (dragHandler != null) { dragEndHandler = result.gameObject.GetComponentInParent <IEndDragHandler>(); result.gameObject.GetComponentInParent <IBeginDragHandler>().OnBeginDrag(pointerData); result.gameObject.GetComponentInParent <IInitializePotentialDragHandler>().OnInitializePotentialDrag(pointerData); dragHandler.OnDrag(pointerData); return; } } }
private void GetTarget() { var pointerData = new PointerEventData(EventSystem.current); pointerData.position = transform.position; EvSystem.RaycastAll(pointerData, raycastResults); foreach (var result in raycastResults) { var selectable = result.gameObject.GetComponentInParent <Selectable>(); if (selectable) { if (selectable.interactable) { Target = selectable; return; } } } Target = null; }