Beispiel #1
0
    public void OnPointerUp(PointerEventData eventData)
    {
        if (pointId == eventData.pointerId)
        {
            isOnTouch = false;
            isOnDrag  = false;

            tmpAxis    = Vector2.zero;
            OldTmpAxis = Vector2.zero;

            axisX.axisState = ETCAxis.AxisState.None;
            axisY.axisState = ETCAxis.AxisState.None;

            if (!axisX.isEnertia && !axisY.isEnertia)
            {
                axisX.ResetAxis();
                axisY.ResetAxis();
                onMoveEnd.Invoke();
            }

            pointId = -1;

            onTouchUp.Invoke();
        }
    }
Beispiel #2
0
    public void OnPointerUp(PointerEventData eventData)
    {
        if (pointId == eventData.pointerId)
        {
            isOnDrag   = false;
            isOnTouch  = false;
            tmpAxis    = Vector2.zero;
            OldTmpAxis = Vector2.zero;

            axisX.axisState = ETCAxis.AxisState.None;
            axisY.axisState = ETCAxis.AxisState.None;

            if (!axisX.isEnertia && !axisY.isEnertia)
            {
                axisX.ResetAxis();
                axisY.ResetAxis();
                onMoveEnd.Invoke();
            }

            onTouchUp.Invoke();


            if (previousDargObject)
            {
                ExecuteEvents.Execute <IPointerUpHandler>(previousDargObject, eventData, ExecuteEvents.pointerUpHandler);
                previousDargObject = null;
            }

            pointId = -1;
        }
    }
    public void OnPointerUp(PointerEventData eventData)
    {
        isOnDrag               = false;
        isOnTouch              = false;
        thumbPosition          = Vector2.zero;
        thumb.anchoredPosition = Vector2.zero;

        axisX.axisState = ETCAxis.AxisState.None;
        axisY.axisState = ETCAxis.AxisState.None;

        if (!axisX.isEnertia && !axisY.isEnertia)
        {
            //Debug.LogWarningFormat("onMoveEnd====>{0}==>{1}", eventData.position.ToString(), eventData.pressPosition.ToString());
            axisX.ResetAxis();
            axisY.ResetAxis();
            tmpAxis    = Vector2.zero;
            OldTmpAxis = Vector2.zero;
            onMoveEnd.Invoke(eventData.position);
        }

        if (joystickType == JoystickType.Dynamic)
        {
            visible        = false;
            isDynamicActif = false;
        }

        onTouchUp.Invoke();
    }
    public void OnPointerUp(PointerEventData eventData)
    {
        isOnDrag               = false;
        isOnTouch              = false;
        thumbPosition          = Vector2.zero;
        thumb.anchoredPosition = Vector2.zero;

        axisX.axisState = ETCAxis.AxisState.None;
        axisY.axisState = ETCAxis.AxisState.None;

        if (!axisX.isEnertia && !axisY.isEnertia)
        {
            axisX.ResetAxis();
            axisY.ResetAxis();
            tmpAxis    = Vector2.zero;
            OldTmpAxis = Vector2.zero;
            onMoveEnd.Invoke();
        }

        if (joystickType == JoystickType.Dynamic)
        {
            visible        = false;
            isDynamicActif = false;
        }

        onTouchUp.Invoke();
    }
Beispiel #5
0
    public void OnPointerUp(PointerEventData eventData)
    {
        isOnTouch = false;
        isOnDrag  = false;

        tmpAxis    = Vector2.zero;
        OldTmpAxis = Vector2.zero;

        removeId(eventData.pointerId);

        if (touchIds.Count > 0)
        {
            GetTouchDirectionDown(touchIds[touchIds.Count - 1].point, eventData.pressEventCamera);
        }

        GetTouchDirectionUp(eventData.position, eventData.pressEventCamera);

        if (touchIds.Count == 0)
        {
            axisX.axisState = ETCAxis.AxisState.None;
            axisY.axisState = ETCAxis.AxisState.None;

            if (!axisX.isEnertia && !axisY.isEnertia)
            {
                axisX.ResetAxis();
                axisY.ResetAxis();
                onMoveEnd.Invoke();
            }
        }

        onTouchUp.Invoke();
    }
Beispiel #6
0
    public void OnPointerDown(PointerEventData eventData)
    {
        if (_activated && !isOnTouch)
        {
            pointId = eventData.pointerId;

            axis.ResetAxis();
            axis.axisState = ETCAxis.AxisState.Down;

            isOnPress = false;
            isOnTouch = true;

            onDown.Invoke();
            ApllyState();
            axis.UpdateButton();
        }
    }
Beispiel #7
0
    public void OnPointerDown(PointerEventData eventData)
    {
        if (_activated && !isOnTouch)
        {
            pointId = eventData.pointerId;

            axis.ResetAxis();
            axis.axisState = ETCAxis.AxisState.Down;

            isOnPress = false;
            isOnTouch = true;

            onDown.Invoke();
            ApllyState();
            axis.UpdateButton();
            // modified by cat heaven
            CrossPlatformInputManager.SetButtonDown(axis.unityAxis);
            // modified by cat heaven
        }
    }
    private void OnUp(bool real = true)
    {
        isOnDrag  = false;
        isOnTouch = false;

        if (isNoReturnThumb)
        {
            noReturnPosition = thumb.position;
            noReturnOffset   = thumbPosition;
        }

        if (!isNoReturnThumb)
        {
            thumbPosition          = Vector2.zero;
            thumb.anchoredPosition = Vector2.zero;

            axisX.axisState = ETCAxis.AxisState.None;
            axisY.axisState = ETCAxis.AxisState.None;
        }

        if (!axisX.isEnertia && !axisY.isEnertia)
        {
            axisX.ResetAxis();
            axisY.ResetAxis();
            tmpAxis    = Vector2.zero;
            OldTmpAxis = Vector2.zero;
            if (real)
            {
                anima.Idleanima();
                onMoveEnd.Invoke();
            }
        }

        if (joystickType == JoystickType.Dynamic)
        {
            visible        = false;
            isDynamicActif = false;
        }

        pointId = -1;

        if (real)
        {
            if (isQStick)
            {
                anima.Qanima();
            }
            onTouchUp.Invoke();
        }
    }
Beispiel #9
0
    public void OnPointerDown(PointerEventData eventData)
    {
        if (_activated)
        {
            axis.ResetAxis();
            axis.axisState = ETCAxis.AxisState.Down;

            isOnPress = false;
            isOnTouch = true;

            onDown.Invoke();
            ApllyState();
        }
    }
Beispiel #10
0
    private void GetTouchDirectionDown(Vector2 position, Camera cam)
    {
        Vector2 localPoint;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(cachedRectTransform, position, cam, out localPoint);

        Vector2 buttonSize = this.rectTransform().sizeDelta / 3f;

        tmpAxis = Vector2.zero;

        if (localPoint.y >= -buttonSize.y / 2f && localPoint.y <= buttonSize.y / 2f && localPoint.x >= -buttonSize.x / 2f && localPoint.x <= buttonSize.x / 2f)
        {
            axisCenter.ResetAxis();
            axisCenter.axisState = ETCAxis.AxisState.Down;
        }

        Vector2 LeftUp    = new Vector2(-this.rectTransform().sizeDelta.x / 2f, this.rectTransform().sizeDelta.y / 2f);
        Vector2 LeftDown  = new Vector2(-this.rectTransform().sizeDelta.x / 2f, -this.rectTransform().sizeDelta.y / 2f);
        Vector2 RightUp   = new Vector2(this.rectTransform().sizeDelta.x / 2f, this.rectTransform().sizeDelta.y / 2f);
        Vector2 RightDown = new Vector2(this.rectTransform().sizeDelta.x / 2f, -this.rectTransform().sizeDelta.y / 2f);

        if ((localPoint.x < -buttonSize.x / 2f && Vector2.Dot(localPoint, LeftUp) > 0 && Vector2.Dot(localPoint, LeftDown) > 0 && dPadAxisCount == DPadAxis.Two_Axis) ||
            (dPadAxisCount == DPadAxis.Four_Axis && localPoint.x < -buttonSize.x / 2f))
        {
            tmpAxis.x = -1;
        }

        // right
        if ((localPoint.x > buttonSize.x / 2f && Vector2.Dot(localPoint, RightUp) > 0 && Vector2.Dot(localPoint, RightDown) > 0 && dPadAxisCount == DPadAxis.Two_Axis) ||
            (dPadAxisCount == DPadAxis.Four_Axis && localPoint.x > buttonSize.x / 2f))
        {
            tmpAxis.x = 1;
        }


        // Up
        if ((localPoint.y > buttonSize.y / 2f && Vector2.Dot(localPoint, LeftUp) > 0 && Vector2.Dot(localPoint, RightUp) > 0 && dPadAxisCount == DPadAxis.Two_Axis) ||
            (dPadAxisCount == DPadAxis.Four_Axis && localPoint.y > buttonSize.y / 2f))
        {
            tmpAxis.y = 1;
        }


        // Down
        if ((localPoint.y < -buttonSize.y / 2f && Vector2.Dot(localPoint, LeftDown) > 0 && Vector2.Dot(localPoint, RightDown) > 0 && dPadAxisCount == DPadAxis.Two_Axis) ||
            (dPadAxisCount == DPadAxis.Four_Axis && localPoint.y < -buttonSize.y / 2f))
        {
            tmpAxis.y = -1;
        }

        // Left
        //      if ( (localPoint.x < -buttonSize.x/2f && localPoint.y > -buttonSize.y/2f && localPoint.y< buttonSize.y/2f && dPadAxisCount== DPadAxis.Two_Axis)
        //    || (dPadAxisCount== DPadAxis.Four_Axis &&  localPoint.x < -buttonSize.x/2f) ){
        //	tmpAxis.x = -1;
        //}

        //// right
        //if ( (localPoint.x > buttonSize.x/2f && localPoint.y> -buttonSize.y/2f && localPoint.y< buttonSize.y/2f && dPadAxisCount== DPadAxis.Two_Axis)
        //	|| (dPadAxisCount== DPadAxis.Four_Axis &&  localPoint.x > buttonSize.x/2f) ){
        //	tmpAxis.x = 1;
        //}


        //// Up
        //if ( (localPoint.y > buttonSize.y/2f && localPoint.x>-buttonSize.x/2f && localPoint.x<buttonSize.x/2f && dPadAxisCount == DPadAxis.Two_Axis)
        //	|| (dPadAxisCount== DPadAxis.Four_Axis &&  localPoint.y > buttonSize.y/2f) ){
        //	tmpAxis.y = 1;
        //}


        //// Down
        //if ( (localPoint.y < -buttonSize.y/2f && localPoint.x>-buttonSize.x/2f && localPoint.x<buttonSize.x/2f && dPadAxisCount == DPadAxis.Two_Axis)
        //	|| (dPadAxisCount== DPadAxis.Four_Axis &&  localPoint.y <- buttonSize.y/2f) ){
        //	tmpAxis.y = -1;
        //}
    }