返回介绍

Input.GetKeyUp 获取键弹起

发布于 2019-12-18 15:37:53 字数 2250 浏览 917 评论 0 收藏 0

JavaScript => public static function GetKeyUp(name: string): bool;
C# => public static bool GetKeyUp(string name);

Description 描述

Returns true during the frame the user releases the key identified by name.

在用户释放给定名字的按键的那一帧返回true。

You need to call this function from the Update function, since the state gets reset each frame. It will not return true until the user has pressed the key and released it again.

你需要在Update方法中调用这个方法,因为该状态每帧获得重置。除非用户按下这个按钮然后重新释放它,否则将不会返回true。

For the list of key identifiers see Input Manager. When dealing with input it is recommended to use Input.GetAxis and Input.GetButton instead since it allows end-users to configure the keys.

按键的标识符列表可以在输入管理器中找到,当处理输入时推荐使用Input.GetAxis和Input.GetButton,它们允许最终用户自定义按键。

JavaScript:

	function Update () {
		if (Input.GetKeyUp ("space"))
			print ("space key was released");
	}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    void Update() {
        if (Input.GetKeyUp("space"))
            print("space key was released");
 
    }
}

JavaScript => public static function GetKeyUp(key: KeyCode): bool;
C# => public static bool GetKeyUp(KeyCode key);

Description 描述

Returns true during the frame the user releases the key identified by the key KeyCode enum parameter.

在用户释放给定键值的按键的那一帧返回true。

JavaScript:

	function Update () {
		if (Input.GetKeyUp (KeyCode.Space))
			print ("space key was released");
	}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    void Update() {
        if (Input.GetKeyUp(KeyCode.Space))
            print("space key was released");
 
    }
}

Input

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文