面向组件编程之Unity 8.按键控制 关键字:bool,GetKey,KeyCode

来源:互联网 发布:淘宝高仿驾驶证 编辑:程序博客网 时间:2024/05/15 04:37
using System.Collections;using System.Collections.Generic;using UnityEngine;public class Part05InputScript : MonoBehaviour {// Use this for initializationvoid Start () {}// Update is called once per framevoid Update () {        //如果按下space键,则isDown为true        bool isDown = Input.GetKeyDown(KeyCode.Space);        if (isDown == true)        {            Debug.Log("space down");        }        //松开第一帧返回        bool isUp = Input.GetKeyUp(KeyCode.LeftAlt);        if (isUp == true)        {            Debug.Log("alt up");        }        //按下期间返回        bool isGe = Input.GetKey(KeyCode.LeftControl);        if (isGe == true)        {            Debug.Log("Control get");        }}}

阅读全文
0 0
原创粉丝点击