public void OnEndDrag(PointerEventData eventData) { if (!this.enabled || !_canDrag || !_isDown) { return; } _isDragging = false; _isDown = false; if (null != OnPrevEndDragAction) { OnPrevEndDragAction.Invoke(this, eventData); } DOTween.Kill(_tool); if (Math.Abs(_dragChangeScale) > float.Epsilon) { _tool.DOScale(_toolCacheScale, 0.25f); } if (Math.Abs(_dragChangeRotate) > float.Epsilon) { _tool.DOLocalRotate(_toolCacheRotation, 0.25f, RotateMode.Fast); } CheckHoverEvent(true); if (_isReleaseAutoBack) { BackPosition(); } else { _tool.position -= new Vector3(0, 0, _dragOffsetZ); if (_prevParent) { _tool.SetParent(_prevParent); _tool.SetSiblingIndex(_toolCacheIndex); _canDrag = true; } } if (null != _pageView) { _pageView.GotoPage(_pageView.CurrentPage); } if (null != _tipDragging) { _tipDragging.SetActive(false); } PlaySoundEndDrag(); SetDragEffectPlay(false); if (null != OnEndDragAction) { OnEndDragAction.Invoke(this, eventData); } GetComponent <Graphic>().raycastTarget = true; }
public void OnEndDrag(PointerEventData eventData) { if (!this.enabled || !this.m_canDrag || !m_isDown) { return; } m_isDragging = false; m_isDown = false; if (OnPrevEndDragAction != null) { OnPrevEndDragAction.Invoke(this, eventData); } DOTween.Kill(dragTarget); if (dragChangeScale != 0f) { dragTarget.DOScale(m_cacheScale, 0.25f); } if (dragChangeRotate != 0f) { dragTarget.DOLocalRotate(m_cacheRotation, 0.25f, RotateMode.Fast); } if (sendHoverEvent) { Collider2D[] cols = null; if (triggerType == TriggerType.Point) { cols = Physics2D.OverlapPointAll(triggerPos.position, rayCastMask, -raycastDepth, raycastDepth); } else if (triggerType == TriggerType.Circle) { cols = Physics2D.OverlapCircleAll(triggerPos.position, triggerRadius, rayCastMask, -raycastDepth, raycastDepth); } else if (triggerType == TriggerType.Range) { cols = Physics2D.OverlapBoxAll(triggerPos.position, triggerRange * 2f, triggerPos.eulerAngles.z, rayCastMask, -raycastDepth, raycastDepth); } if (cols != null && cols.Length > 0) { if (OnDropColliderAction != null) { OnDropColliderAction(this, cols); } else { foreach (Collider2D col in cols) { if (col.gameObject != gameObject) { col.SendMessage(onDropMethodName, dragTarget.gameObject, SendMessageOptions.DontRequireReceiver); } } gameObject.SendMessage(onDropMethodName, cols, SendMessageOptions.DontRequireReceiver); } } } if (releaseAutoBack) { BackPosition(); } else { dragTarget.position -= new Vector3(0, 0, dragOffsetZ); if (m_parent) { dragTarget.SetParent(m_parent); } dragTarget.SetSiblingIndex(m_cacheIndex); this.m_canDrag = true; } if (OnEndDragAction != null) { OnEndDragAction(this, eventData); } this.GetComponent <Graphic>().raycastTarget = true; }
void OnPointerUpHandler() { m_isDown = false; if (!this.enabled || !m_isDragging) { return; } m_isDragging = false; if (OnPrevEndDragAction != null) { OnPrevEndDragAction.Invoke(this); } DOTween.Kill(dragTarget); if (dragChangeScale != 0f) { dragTarget.DOScale(m_cacheScale, 0.25f); } if (dragChangeRotate != 0f) { dragTarget.DOLocalRotate(m_cacheRotation, 0.25f, RotateMode.Fast); } if (releaseAutoBack) { BackPosition(); } else { dragTarget.position -= new Vector3(0, 0, dragOffsetZ); foreach (SpriteRenderer render in dragTarget.GetComponentsInChildren <SpriteRenderer>()) { render.sortingLayerName = m_sortLayerName; render.sortingOrder -= dragChangeOrder; } } if (sendHoverEvent) { Collider2D[] cols = null; if (triggerType == TriggerType.Point) { cols = Physics2D.OverlapPointAll(triggerPos.position, dropRayCastMask, -raycastDepth, raycastDepth); } else if (triggerType == TriggerType.Circle) { cols = Physics2D.OverlapCircleAll(triggerPos.position, triggerRadius, dropRayCastMask, -raycastDepth, raycastDepth); } else if (triggerType == TriggerType.Range) { cols = Physics2D.OverlapBoxAll(triggerPos.position, triggerRange * 2f, triggerPos.eulerAngles.z, dropRayCastMask, -raycastDepth, raycastDepth); } if (cols != null && cols.Length > 0) { if (OnDropColliderAction != null) { OnDropColliderAction(this, cols); } else { foreach (Collider2D col in cols) { if (col.gameObject != gameObject) { col.SendMessage(onDropMethodName, dragTarget.gameObject, SendMessageOptions.DontRequireReceiver); } if (dropIgnoreBottom) { break; } } gameObject.SendMessage(onDropMethodName, cols, SendMessageOptions.DontRequireReceiver); } } } if (OnEndDragAction != null) { OnEndDragAction(this); } }