using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test_input : MonoBehaviour {
string message;
void Move(){
var inputMid = Input.GetKey (KeyCode.Mouse2);
var inputX = Input.GetAxis ("Mouse X");
var inputY = Input.GetAxis ("Mouse Y");
if (inputMid) {
this.transform.Translate(new Vector3 (0f, -inputY, 0f));
this.transform.Translate(new Vector3 (-inputX, 0f, 0f));
}
}
void ChangeRay(){
var inputX = Input.GetAxis ("Horizontal");
var inputY = Input.GetAxis ("Vertical");
this.transform.Rotate(new Vector3 (0f, inputX, 0f));
this.transform.Rotate(new Vector3 (-inputY, 0f, 0f));
}
void ChangeSize(){
var delteSize = Input.GetAxis ("Mouse ScrollWheel");
var Size = this.GetComponent<Camera> ().orthographicSize;
Size = Size -delteSize*10;
this.GetComponent<Camera> ().orthographicSize = Size;
}
void changeDis(){
var distance = Input.GetAxis ("Mouse ScrollWheel");
this.transform.position = this.transform.position + this.transform.rotation * new Vector3 (0f, 0f, distance*10.0f);
if (this.transform.position.y > 50.0f) {
this.GetComponent<Camera> ().orthographic = true;
}else {
this.GetComponent<Camera> ().orthographic = false;
}
}
void Update () {
Move ();
ChangeSize ();
ChangeRay ();
changeDis ();
message = Input.mousePosition.x + "," + Input.mousePosition.y + "," + Input.mousePosition.z;
}
void OnGUI(){
GUILayout.TextArea (message, 100);
}
}
unity 漫游相机
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 转自:http://dev.arinchina.com/177wz/ar9641/9641/1 启用相机摄影摄像能...
- 星盟冲突,星区视角下的缩放效果图: 一. 手势系统 使用插件EasyTouch监听移动缩放 二. 相机looka...