您的位置:首页 > 移动开发 > Unity3D

Unity键盘鼠标监听事件

2017-06-22 14:45 926 查看
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class C_3_8_1 : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
// 按下键盘A键
if (Input.GetKeyDown(KeyCode.A)){
Debug.Log ("你按下了A");
}
// 按住键盘A键
if (Input.GetKey(KeyCode.A)) {
Debug.Log ("你按住了A");
}
// 抬起键盘A键
if (Input.GetKeyUp(KeyCode.A)) {
Debug.Log ("你抬起了A");
}

// 按下键盘左Shift键
if (Input.GetKeyDown(KeyCode.LeftShift)) {
Debug.Log ("你按下了左Shift");
}
// 按住键盘左Shift键
if (Input.GetKey(KeyCode.LeftShift)) {
Debug.Log ("你按住了左Shift");
}
// 按下键盘左Shift键
if (Input.GetKeyUp(KeyCode.LeftShift)) {
Debug.Log ("你抬起了左Shift");
}

// 按下鼠标左键
if (Input.GetMouseButtonDown(0)) {
Debug.Log ("你按下了鼠标左键");
}
// 按住鼠标左键
if (Input.GetMouseButton(0)) {
Debug.Log ("你按住了鼠标左键");
}
// 抬起鼠标左键
if (Input.GetMouseButtonUp(0)) {
Debug.Log ("你抬起了鼠标左键");
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: