이건 나도 이제 공부해야 할 과제 !
으.. 역시 쉬운 프로그래밍은 없군.
아.. 테스트를 해봐야 하는데 ㅠㅠ!
출처 : http://answers.unity3d.com/questions/22500/how-to-zoom-and-pan-when-you-pinchswipe-across-scr.html
- using UnityEngine;
- using System.Collections;
- public class CameraZoomPinch : MonoBehaviour
- {
- public int speed = 4;
- public Camera selectedCamera;
- private float touchDelta = 0.0F;
- private Vector2 prevDist = new Vector2(0,0);
- private Vector2 curDist = new Vector2(0,0);
- // Update is called once per frame
- void Update ()
- {
- if (Input.touchCount == 2 && Input.GetTouch(0).phase == TouchPhase.Moved && Input.GetTouch(1).phase == TouchPhase.Moved)
- {
- curDist = Input.GetTouch(0).position - Input.GetTouch(1).position; //current distance between finger touches
- prevDist = ((Input.GetTouch(0).position - Input.GetTouch(0).deltaPosition) -
(Input.GetTouch(1).position - Input.GetTouch(1).deltaPosition)); //difference in previous locations using delta positions - touchDelta = curDist.magnitude - prevDist.magnitude;
- if ((touchDelta < 0)) //
- {
- selectedCamera.fieldOfView = Mathf.Clamp(selectedCamera.fieldOfView + (1 * speed),15,90);
- }
- if ((touchDelta > 0))
- {
- selectedCamera.fieldOfView = Mathf.Clamp(selectedCamera.fieldOfView - (1 * speed),15,90);
- }
- }
- }
- }
'Programmer의 텅빈 공간 > Unity3D' 카테고리의 다른 글
멀티 터치 (2 터치)를 이용한 zoom (0) | 2014.05.06 |
---|---|
유니티 창 여러개 띄우기 (0) | 2014.05.06 |
마우스 우 클릭으로 확대 축소 하기 (0) | 2014.05.06 |
패키지 사용할 때 (0) | 2014.05.06 |
NGUI 참고 사이트 (0) | 2014.05.06 |