通过UNITY自带的Touch可以实现安卓和IOS两个平台都兼容。效果是通过单手指滑动摄像机绕着目标点旋转(看起来就像是物体在旋转)。通过双指操作拉近或者拉远摄像机实现放大缩小操作。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CamRotation : MonoBehaviour {
public Transform target;
public float distance = 30.0f;
//上下左右滑动速度
float xSpeed = 250.0f;
float ySpeed = 120.0f;
//缩放限制系数(拉近拉远的距离)
float yMinLimit = -20;
float yMaxLimit = 80;
//摄像头的位置
float x = 0.0f;
float y =