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...