Beispiel #1
0
        void IEndDragHandler.OnEndDrag(PointerEventData eventData)
        {
            if (!PTUIEventUtil.Interactable(gameObject) || !mDragBegan)
            {
                return;
            }

            UIEventLockManager.Instance.SendMsg(new UIUnlockObjEventMsg(gameObject));

            if (mCurState == State.Scroll)
            {
                mOnScrollEndedEvent.InvokeGracefully();
                ExecuteEvents.Execute(ScrollRect.gameObject, eventData,
                                      delegate(ScrollRect handler, BaseEventData data) { handler.OnEndDrag(data as PointerEventData); });

                mCurState = State.Idle;
            }
            else if (mCurState == State.Drag)
            {
                mOnDragEndedEvent.InvokeGracefully();

                if (mIdleStateWhenDragEnd)
                {
                    mCurState = State.Idle;
                }
            }

            mDragBegan = false;
        }
Beispiel #2
0
        void IBeginDragHandler.OnBeginDrag(PointerEventData eventData)
        {
            if (!PTUIEventUtil.Interactable(gameObject))
            {
                return;
            }
            UIEventLockManager.Instance.SendMsg(new UILockObjEventMsg(gameObject));

            mCurrentDragCalculated = false;
            mDragBeganMousePos     = (transform.parent as RectTransform).GetLocalPosInRect();
            mDragBegan             = true;
        }
Beispiel #3
0
        void IDragHandler.OnDrag(PointerEventData eventData)
        {
            if (!PTUIEventUtil.Interactable(gameObject) || !mDragBegan)
            {
                return;
            }

            if (!mCurrentDragCalculated && mCurState == State.Idle)
            {
                var offsetFromBegan = (transform.parent as RectTransform).GetLocalPosInRect() - mDragBeganMousePos;
                if (offsetFromBegan.magnitude > 10)
                {
                    mCurrentDragCalculated = true;

                    if (CheckBeganDragged(offsetFromBegan))
                    {
                        mCurState = State.Drag;
                        mOnDragBeganEvent.InvokeGracefully();
                    }
                    else
                    {
                        mCurState = State.Scroll;
                        ExecuteEvents.Execute(ScrollRect.gameObject, eventData,
                                              delegate(ScrollRect handler, BaseEventData data) { handler.OnBeginDrag(data as PointerEventData); });
                        mOnScrollBeganEvent.InvokeGracefully();
                    }

                    return;
                }
            }
            else if (!mCurrentDragCalculated && mCurState == State.Drag)
            {
                mOnDragBeganEvent.InvokeGracefully();
                mCurrentDragCalculated = true;
                return;
            }

            switch (mCurState)
            {
            case State.Drag:
                mOnDragEvent.InvokeGracefully();
                break;

            case State.Scroll:
                mOnScrollEvent.InvokeGracefully();
                ExecuteEvents.Execute(ScrollRect.gameObject, eventData,
                                      delegate(ScrollRect handler, BaseEventData data) { handler.OnDrag(data as PointerEventData); });
                break;
            }
        }