/// <summary> /// Uses event system to raycast to all UI elements as the elemnt is being dragged. /// </summary> /// <returns></returns> private IEnumerator DropcastHover() { _originParent = dynamicTransform.parent; originalDepositArea = _activeDepositArea; while (true) { // Raycast with even system _currentDropcastData = new PointerEventData(EventSystem.current) { position = Input.mousePosition }; EventSystem.current.RaycastAll(_currentDropcastData, _dropcastResults); // Act on raycast results if (_dropcastResults.Count == 0 && _activeDepositArea != null) { OnNullDropcast(); } else { foreach (RaycastResult result in _dropcastResults) { DepositArea d = result.gameObject.GetComponent <DepositArea>(); if (d != null) { if (d.gameObject != gameObject) { if (d != _activeDepositArea) { if (_activeDepositArea != null) { _activeDepositArea.OnDroppableRaycastReceiveExit(this); OnDragElementContainerHoverExit(_activeDepositArea, d); } _activeDepositArea = d; _activeDepositArea.OnDroppableRaycastReceiveEnter(this); OnDragElementContainerHoverEnter(_activeDepositArea); } else { _activeDepositArea.OnDroppableRaycastReceiveStay(this); } } break; } else { dynamicTransform.SetParent(result.gameObject.transform); OnNullDropcast(); } } } yield return(null); } }
/// <summary> /// /// </summary> private void OnNullDropcast() { if (_activeDepositArea != null) { _activeDepositArea.OnDroppableRaycastReceiveExit(this); OnDragElementContainerHoverExit(_activeDepositArea, null); } _activeDepositArea = null; }
public virtual void OnDragElementContainerHoverEnter(DepositArea container) { dynamicTransform.SetParent(container.depositAreaTransform); // Inform decorators foreach (IDropElementEventReceivable d in _decorators) { d.OnDragElementContainerHoverEnter(container); } }
public virtual void OnDragElementContainerHoverExit(DepositArea outContainer, DepositArea inContainer) { dynamicTransform.SetParent(_defaultParent); dynamicTransform.localScale = _defaultScale; // Inform decorators foreach (IDropElementEventReceivable d in _decorators) { d.OnDragElementContainerHoverExit(outContainer, inContainer); } }
public virtual void OnDragElementDrop(DepositArea container) { // Cancel any momentum we may have after dragging if (container != null && _originParent != container.depositAreaTransform && _rectIsSlidingWithMomentum) { _rectIsSlidingWithMomentum = false; StopCoroutine(nameof(OnMomentumSlideFrame)); } // If we drop out of the area we were previously in, we need to inform that area if (originalDepositArea != null && _activeDepositArea != originalDepositArea) { originalDepositArea.OnDroppableRemove(this); } dynamicTransform.localScale = _defaultScale; // Inform decorators foreach (IDropElementEventReceivable d in _decorators) { d.OnDragElementDrop(container); } }
protected virtual void Awake() { _depositArea = GetComponent <DepositArea>(); }
public virtual void OnDragElementDrop(DepositArea container) { }
public virtual void OnDragElementContainerHoverExit(DepositArea outContainer, DepositArea inContainer) { }
public virtual void OnDragElementContainerHoverEnter(DepositArea container) { }