我是靠谱客的博主 潇洒砖头,这篇文章主要介绍Horizontal,vertical,Input_Mouse,Input_Key,现在分享给大家,希望可以做个参考。

复制代码
1
鼠标获取
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using UnityEngine; using System.Collections; public class Input_Mouse : MonoBehaviour { void Update() { // if (Input.GetMouseButtonDown (0)) { // Debug.Log ("按下了鼠标左键"); // } // // if (Input.GetMouseButtonUp (0)) { // Debug.Log ("抬起了鼠标左键"); // } // // if (Input.GetMouseButton (0)) { // Debug.Log ("按住了鼠标左键"); // } Debug.Log (Input.mousePosition); } }
复制代码
1

 按键获取

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using UnityEngine; using System.Collections; public class Input_Key : MonoBehaviour { void Update() { //当用户按下了空格键盘,if成立(为真) if (Input.GetKeyDown (KeyCode.Space)) { Debug.Log ("按下了空格!!!"); } if (Input.GetKey (KeyCode.Space)) { Debug.Log ("按住了空格!!!"); } if (Input.GetKeyUp (KeyCode.Space)) { Debug.Log ("抬起了空格!!!"); } } }

  WASD获取

复制代码
1
using UnityEngine; using System.Collections; public class Virtual : MonoBehaviour { void Update() { float h = Input.GetAxis ("Horizontal"); float v = Input.GetAxis ("Vertical"); Debug.Log (v); } }

 

转载于:https://www.cnblogs.com/VR-1024/p/6011042.html

最后

以上就是潇洒砖头最近收集整理的关于Horizontal,vertical,Input_Mouse,Input_Key的全部内容,更多相关Horizontal内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(70)

评论列表共有 0 条评论

立即
投稿
返回
顶部