7
марта
Класс написан для того, чтобы дать возможность жестами двух пальцев, зумить ортографическую камеру. НА вроде Google Maps в мобилке. Без особого труда, класс можно перекрутить на обычную камеру.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | using UnityEngine; //Creating by Neodrop //neodrop@unity3d.ru [RequireComponent(typeof(Camera))] public class Zoomer : MonoBehaviour { public float stepPerSecond = 1f, orthoMin = 3f, orthoMax = 6f; float lastDistance = 0f; void FixedUpdate() { if (iPhoneInput.touchCount != 2) { lastDistance = 0; return; } if (iPhoneInput.touches[0].phase != iPhoneTouchPhase.Moved && iPhoneInput.touches[1].phase != iPhoneTouchPhase.Moved) { lastDistance = 0; return; } iPhoneTouch[] touch = iPhoneInput.touches; float distance = Vector2.Distance(touch[0].position, touch[1].position); if (distance == lastDistance) return; float touchDistance = (touch[1].position - touch[0].position).magnitude; float lastTouchDistance = ((touch[1].position - touch[1].deltaPosition) - (touch[0].position - touch[0].deltaPosition)).magnitude; float deltaPinch = touchDistance - lastTouchDistance; camera.orthographicSize += deltaPinch * stepPerSecond * Time.deltaTime; if (camera.orthographicSize < orthoMin) camera.orthographicSize = orthoMin; else if (camera.orthographicSize > orthoMax) camera.orthographicSize = orthoMax; lastDistance = distance; } } |
4 комментария на «Zoom для ортографической камеры»
Ваш отзыв
Вы должны войти, чтобы оставлять комментарии.
23 Дек 2013 в 13:34
lewisohn@dora.progandist” rel=”nofollow”>.…
спс….
23 Авг 2014 в 5:26
icicle@multitudinous.corrosion” rel=”nofollow”>.…
благодарю!…
24 Авг 2014 в 2:47
irons@augment.descendents” rel=”nofollow”>.…
благодарен!…
24 Авг 2014 в 10:04
affair@ximenez.infective” rel=”nofollow”>.…
благодарен….