将两个摄像机放在同一父物体下,然后分别设置左边摄像机参数Viewport Rect(x=0,y=0,w=0.5,h=1)右摄像机参数Viewport Rect(x=0.5,y=0,w=0.5,h=1)
绕物体旋转可以旋转两个摄像机父物体,CheckAngle()是为了将超过360度和一些奇怪旋转角度的问题去除,同时去除了触碰到UI也会旋转的问题,代码如下(target为相机围绕的中心)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class CameraRotate : MonoBehaviour
{
public Transform target { get; set; }
private float speed = 1f;
bool uiTouchedFlag = false;
private Vector3 centerPos;
// Use this for initialization
void Start()
{
//target = transform;
}
// Update is called once per frame
void Update()
{
Rotate();
}
Vector3 oldPos;
Quaternion oldRot;
floa