utyasheva.irina 07 окт 2015, 17:24
У меня получилось сделать
if (Input.touchCount == 1)
{
DebugHUD.Log("Android");
Touch currentTouch = Input.GetTouch(0);
if (currentTouch.phase == TouchPhase.Began)
this.dragOrigin = this.getWorldPoint(currentTouch.position);
if (currentTouch.phase == TouchPhase.Moved)
{
Vector3 worldDelta = getWorldPoint(currentTouch.position) - this.dragOrigin;
//Vector3 move = new Vector3 (worldDelta.x * dragSpeed, 0, worldDelta.y * dragSpeed);
Vector3 move = new Vector3 (worldDelta.x * dragSpeed, worldDelta.y * dragSpeed, 0);
//DebugHUD.Log(getWorldPoint(move));
//Camera.main.transform.Translate (move, Space.World);
Camera.main.transform.Translate(move.x, move.y, 0);
}
}
if (Input.touchCount == 2 && Input.GetTouch(0).phase == TouchPhase.Moved && Input.GetTouch(1).phase == TouchPhase.Moved)
{
Vector2 cameraViewsize = new Vector2 (Camera.main.pixelWidth, Camera.main.pixelHeight);
Touch touchOne = Input.GetTouch(0);
Touch touchTwo = Input.GetTouch(1);
Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;
Vector2 touchTwoPrevPos = touchTwo.position - touchTwo.deltaPosition;
float prevTouchDeltaMag = (touchOnePrevPos - touchTwoPrevPos).magnitude;
float touchDeltaMag = (touchOne.position - touchTwo.position).magnitude;
float deltaMagDiff = touchDeltaMag - prevTouchDeltaMag;
//Camera.main.orthographicSize += deltaMagDiff * orthoZoomSpeed;
///Camera.main.orthographicSize = Mathf.Clamp (_camera.orthographicSize, minZoom, maxZoom) - 0.001f;
Vector3 movement = Camera.main.transform.TransformDirection (Camera.main.transform.forward);
Camera.main.transform.Translate(movement * deltaMagDiff * 5);
}