标签:des class blog http tar com
1.摄像机围绕物体旋转
using UnityEngine; using System.Collections; public class CameraVirtual : MonoBehaviour { //旋转的物体 public GameObject building; //用来记录鼠标的位置,以便计算旋转幅度 Vector2 p1, p2; // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(1)) { p1 = new Vector2(Input.mousePosition.x, Input.mousePosition.y);//鼠标右键按下时记录鼠标位置p1 } if (Input.GetMouseButton(1)) { p2 = new Vector2(Input.mousePosition.x, Input.mousePosition.y);//鼠标右键拖动时记录鼠标位置p2 //下面开始旋转,仅在水平方向上进行旋转 float dx = p2.x - p1.x; transform.RotateAround(building.transform.position, Vector3.up, dx * Time.deltaTime); } } }
2. 鼠标控制摄像机远近
参考: 1 2 3
标签:des class blog http tar com
原文地址:http://www.cnblogs.com/code1992/p/3791705.html