1 void Update()
 2     {
 3         //左Ctrl键
 4         if (Input.GetKey(KeyCode.LeftControl))
 5         {
 6             B_LeftCtrl = true;
 7         }
 8         else
 9         {
10             B_LeftCtrl = false;
11         }
12 
13         if (Input.GetMouseButton(0) && B_LeftCtrl)//鼠标左键+左Ctrl
14         {
15             float mouseX = Input.GetAxis("Mouse X");//获取鼠标X轴滑动参数
16             float mouseY = Input.GetAxis("Mouse Y");//获取鼠标Y轴滑动参数
17             //鼠标XY轴滑动控制物体旋转
18             GameObject.Find("地形").transform.Rotate(new Vector3(mouseY * Time.deltaTime * rotateSpeed, -mouseX * Time.deltaTime * rotateSpeed));
19         } 
20 
21         if (Input.GetMouseButton(1) && B_LeftCtrl)//鼠标右键+左Ctrl
22         {  
23             float mouseX = Input.GetAxis("Mouse X");//获取鼠标X轴滑动参数
24             float mouseY = Input.GetAxis("Mouse Y");//获取鼠标Y轴滑动参数  
25              
26             GameObject.Find("地形").transform.Translate(new Vector3(mouseX * Time.deltaTime * moveSpeed,mouseY * Time.deltaTime * moveSpeed,0));
27         }
28 
29         if (B_LeftCtrl)//左Ctrl键
30         {
31             //W、A、S、D 控制移动
32             float horizontal = Input.GetAxis("Horizontal"); //获取横轴参数。 
33             float vertical = Input.GetAxis("Vertical"); //获取垂直参数。  
34 
35             GameObject.Find("地形").transform.Translate(new Vector3(horizontal * Time.deltaTime * moveSpeed, 0, vertical * Time.deltaTime * moveSpeed));
36 
37             //鼠标中键控制物体滚轴缩放
38             float mouseScrollWheel = Input.GetAxis("Mouse ScrollWheel");  
39             GameObject.Find("地形").transform.localScale += new Vector3(mouseScrollWheel, mouseScrollWheel, mouseScrollWheel);
40         }
41     }

 

posted on 2020-06-11 17:41  _萧朗  阅读(1060)  评论(0编辑  收藏  举报