1.首先新建一个空物体命名为“CameraController” 2.在“CameraController”对象下,创建一个名为“CameraObject”的空对象 3.将“Main Camera”拖动到“CameraObject”对象层级下 4.新建一个“Cube”物体 5.在“CameraController”对象上,创建一个名字为“RotateZoomObject”的C#脚本;(代码如下) using System; using...
这个是需要用的DOTween的,将此脚本挂到相机上,然后再添加相机跟随的目标即可,具体代码如下 using DG.Tweening; using UnityEngine; public class FollowTrackingCamera : MonoBehaviour { public static FollowTrackingCamera _Instance; // Camera target to look at. //相机跟随目标 public Transform target; //相机...
{//以物体上方为旋转轴(Vector3.up == new Vector3(0, 1.0f, 0)),物体左右旋转角度与鼠标横向移动距离相关,变化速率2ftransform.RotateAround(newVector3(0,0,0), Vector3.up, Time.deltaTime * offset.x *2f); // transform.RotateAround(rotateCenter.localPosition, Vector3.up, Time.deltaTime * offs...
transform.Translate(Vector3.forward * Input.GetAxis("Mouse ScrollWheel") * wheelSpeed); Tanks.Translate(Vector3.forward * Input.GetAxis("Mouse ScrollWheel") * wheelSpeed); //方块与相机保持相应距离 distance = JvLi; } else { //限制缩放 if ((Input.GetAxis("Mouse ScrollWheel") < 0 || dis...
#if UNITY_EDITOR AroundByMouseInput(); #elif UNITY_ANDROID || UNITY_IPHONE AroundByMobileInput(); #endif } //记录上一次手机触摸位置判断用户是在左放大还是缩小手势 private Vector2 oldPosition1; private Vector2 oldPosition2; private bool m_IsSingleFinger; ...