public static bool GetKeyUp (string name);

Description

在用户释放 name 标识的键的帧期间返回 true。

您需要从 Update 函数调用该函数(因为每帧都会重置状态)。 在用户按下键并再次释放键之前,它不会返回 true。

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

using UnityEngine;
using System.Collections;

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

public static bool GetKeyUp (KeyCode key);

Description

在用户释放 key KeyCode 枚举参数标识的键的帧期间返回 true。

using UnityEngine;

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