Exemplo n.º 1
0
        /// <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);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 private void OnNullDropcast()
 {
     if (_activeDepositArea != null)
     {
         _activeDepositArea.OnDroppableRaycastReceiveExit(this);
         OnDragElementContainerHoverExit(_activeDepositArea, null);
     }
     _activeDepositArea = null;
 }
Exemplo n.º 3
0
        public virtual void OnDragElementContainerHoverEnter(DepositArea container)
        {
            dynamicTransform.SetParent(container.depositAreaTransform);

            // Inform decorators
            foreach (IDropElementEventReceivable d in _decorators)
            {
                d.OnDragElementContainerHoverEnter(container);
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
 protected virtual void Awake()
 {
     _depositArea = GetComponent <DepositArea>();
 }
Exemplo n.º 7
0
 public virtual void OnDragElementDrop(DepositArea container)
 {
 }
Exemplo n.º 8
0
 public virtual void OnDragElementContainerHoverExit(DepositArea outContainer, DepositArea inContainer)
 {
 }
Exemplo n.º 9
0
 public virtual void OnDragElementContainerHoverEnter(DepositArea container)
 {
 }