이건 나도 이제 공부해야 할 과제 !

 

으.. 역시 쉬운 프로그래밍은 없군. 

 

아.. 테스트를 해봐야 하는데 ㅠㅠ!

 

출처 : http://answers.unity3d.com/questions/22500/how-to-zoom-and-pan-when-you-pinchswipe-across-scr.html

 

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class CameraZoomPinch : MonoBehaviour
  5. {
  6.     public int speed = 4;
  7.     public Camera selectedCamera;
  1.     private float touchDelta = 0.0F;
  2.     private Vector2 prevDist = new Vector2(0,0);
  3.     private Vector2 curDist = new Vector2(0,0); 
  4.     // Update is called once per frame
  5.     void Update ()
  6.     {
  7.        if (Input.touchCount == 2 && Input.GetTouch(0).phase == TouchPhase.Moved && Input.GetTouch(1).phase == TouchPhase.Moved)
  8.        { 
  9.          curDist = Input.GetTouch(0).position - Input.GetTouch(1).position; //current distance between finger touches
  10.          prevDist = ((Input.GetTouch(0).position - Input.GetTouch(0).deltaPosition) -
    (Input.GetTouch(1).position - Input.GetTouch(1).deltaPosition)); //difference in previous locations using delta positions
  11.          touchDelta = curDist.magnitude - prevDist.magnitude;
  12.  
  13.          if ((touchDelta < 0)) //
  14.          {
  15.               selectedCamera.fieldOfView = Mathf.Clamp(selectedCamera.fieldOfView + (1 * speed),15,90);
  16.          }
  17.          if ((touchDelta > 0))
  18.          {
    1.           selectedCamera.fieldOfView = Mathf.Clamp(selectedCamera.fieldOfView - (1 * speed),15,90);
  19.          }
  20.  
  21.        }    
  22.     }
  23. }


+ Recent posts