MouseOrbit
来源:互联网 发布:php加密方式 编辑:程序博客网 时间:2024/05/17 23:03
using UnityEngine;using System.Collections;public class MouseOrbit : MonoBehaviour{ public Transform target; float distance = 30.0f; float xSpeed = 250.0f; float ySpeed = 120.0f; float yMinLimit = -20; float yMaxLimit = 80; private float x = 0.0f; private float y = 0.0f; void Start() { var angles = transform.eulerAngles; x = angles.y; y = angles.x; // Make the rigid body not change rotation if (GetComponent<Rigidbody>()) { GetComponent<Rigidbody>().freezeRotation = true; } } void LateUpdate() { if (Input.GetMouseButton(0)) { if (target) { x += Input.GetAxis("Mouse X") * xSpeed * 0.02f; y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f; y = ClampAngle(y, yMinLimit, yMaxLimit); var rotation = Quaternion.Euler(y, x, 0); var position = rotation * new Vector3(0.0f, 0.0f, -distance) + target.position; transform.rotation = rotation; transform.position = position; } } } static float ClampAngle(float angle, float min, float max) { if (angle < -360) { angle += 360; } if (angle > 360) { angle -= 360; } return Mathf.Clamp(angle, min, max); }}
0 0
- MouseOrbit
- MouseOrbit增加中轴缩放功能
- Unity3D自带Package Scripts 之MouseOrbit
- [脚本] 改自相机的MouseOrbit脚本,增加了相机距对象的高度,鼠标滚轮操作还有鼠标右键移动相机操作
- LeetCode
- 鼠标旋转物体脚本
- 自定义Gradle task
- Eclipse工具
- 开源项目合集
- MouseOrbit
- @ResponseBody注解的作用
- x64 win64编译环境下ADO链接Access数据库的问题解决
- Windows未能启动,原因可能是最近更改了硬件或软件,解决此问题的步骤...
- 第一天深入了解 指针 引用吧
- JavaScript的null类型说明
- 【分布式Tensorflow(0.11.0)问题 未解决】 alexnet_v2/pool1/MaxPool : tensor_in must be 4-dimensional
- 启动tomcat小猫不显示
- LB/LVS之KeepAlived