今天写一个demo,要用到鼠标键盘控制三维视角,因此写了个脚本用于控制. 该脚本可以用于即时战略类游戏的视角,提供了缩进,拉伸,旋转.同时按住鼠标右键不放,移动鼠标可以实现第一人称视角的效果. using UnityEngine; using System.Collections; public class CameraController : MonoBehaviour { public float near = 20.0f; public float far = 100.0f; public…
工作的原因,今天就只写了unity下的鼠标左键控制摄像机的视角左右上下调节:明天,补齐.[有诸多参考,着实是需要多多加油的] using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class CameraMove : MonoBehaviour { public Vector3 target; private Vec…
1. 摄像机预览物体 上下左右远近 把CameraFollow脚本赋给Camera,把要观察的对象赋给target using UnityEngine; using System.Collections; public class CameraFollow : MonoBehaviour { public Transform target; public float targetHeight; public float distance; public int maxDistance; publ…
把此类放到 Editor下使用就OK using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEditor; /// <summary> /// 添加鼠标右键事件 /// </summary> [InitializeOnLoad] [ExecuteInEditMode] public static class AddMouseRight { static Ad…