Input.GetKeyUp 获取键弹起

static function GetKeyUp (name : string) : bool

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,它们允许最终用户自定义按键。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Update() {
		if (Input.GetKeyUp("space"))
			print("space key was released");

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

• static function GetKeyUp (key : KeyCode) : bool

Description描述

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

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

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Update() {
		if (Input.GetKeyUp(KeyCode.Space))
			print("space key was released");

	}
}
function Update () {
	if (Input.GetKeyUp (KeyCode.Space))
		print ("space key was released");
}
Page last updated: 2011-3-12