Exemplo n.º 1
0
    void Update()
    {
        if (Input.touchCount == 1)
        {
            if (SelectionHandler.IsPointerOverUIObject())
            {
                return;
            }

            if (Input.GetTouch(0).phase == TouchPhase.Moved)
            {
                cameraVelocity = -modifiedVelocity * ((Input.GetTouch(0).deltaPosition) * ((Input.GetTouch(0).deltaTime) / 1));

                if (cr_DecelerateCamMovement == null)
                {
                    cr_DecelerateCamMovement = StartCoroutine(CamVelocityDecay());
                }
            }
        }
        else if (Input.touchCount == 2)
        {
            if (Input.GetTouch(1).phase == TouchPhase.Began)
            {
                doubleTouchStartDistance = DistanceBetweenTouches(0, 1);
            }
            if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(1).phase == TouchPhase.Moved)
            {
                doubleTouchNewDistance      = DistanceBetweenTouches(0, 1);
                camCamera.orthographicSize += (doubleTouchNewDistance - doubleTouchStartDistance) * -zoomFactor;
                doubleTouchStartDistance    = doubleTouchNewDistance;

                zoomInterpolate  = (camCamera.orthographicSize - mm_ZoomBounds.Min) / mm_ZoomBounds.Difference;
                modifiedVelocity = mm_VelocityModifier.Lerp(zoomInterpolate);

                if (camCamera.orthographicSize > mm_ZoomBounds.Max)
                {
                    camCamera.orthographicSize = mm_ZoomBounds.Max;
                }
                else if (camCamera.orthographicSize < mm_ZoomBounds.Min)
                {
                    camCamera.orthographicSize = mm_ZoomBounds.Min;
                }
            }
        }
    }