Exemplo n.º 1
0
    protected IEnumerator DoAction()
    {
        // MDebug.Log("!camera startZoom");
        float StartTouchDistance   = Input.GetAxis("Mouse ScrollWheel") != 0 ? 0 : (Input.touches[0].position - Input.touches[1].position).magnitude;
        float LastTouchDistance    = StartTouchDistance;
        float CurrentDeltaDistance = 0;
        float CurrentTouchDistance = 0;

        Active = true;

        while (CanStartInput())
        {
            if (Input.GetAxis("Mouse ScrollWheel") != 0)
            {
                CurrentTouchDistance = Mathf.Clamp(Input.GetAxis("Mouse ScrollWheel") * ZoomSensitivity / Time.deltaTime, -MaxZoomStep, MaxZoomStep);
            }
            else
            {
                CurrentTouchDistance = (Input.touches[0].position - Input.touches[1].position).magnitude / ZoomSensitivity;
            }

            CurrentDeltaDistance = (CurrentTouchDistance - LastTouchDistance);

            LastTouchDistance = CurrentTouchDistance;

            SetTargetDistance(CurrentTouchDistance);
            yield return(null);
        }

        StartCoroutine(M_Math.DelayForFrames(5));
        Active = false;

        //MDebug.Log("!camera endzoom");


        yield break;
    }
Exemplo n.º 2
0
    IEnumerator DoPan()
    {
        Active = true;
        Vector3 startDragPos = M_Math.GetInputPos();

        MDebug.Log("^cameraDOPAN");
        while (CanStartInput())
        {
            Vector3 mousePos = M_Math.GetInputPos();
            Vector3 delta    = mousePos - startDragPos;
            Debug.DrawRay(startDragPos, delta, Color.green);

            smoothMove = -Vector3.ClampMagnitude(delta * Time.fixedDeltaTime * 10, delta.magnitude);

            AttemptMove(smoothMove);
            yield return(null);
        }

        yield return(StartCoroutine(M_Math.DelayForFrames(frames_delay)));

        Active = false;

        yield break;
    }