Version: 2017.3
public static bool GetKey (string name);

説明

name によって識別されるキーを押している間、true を返します。オート射撃のようなものと考えてください

キーの識別リストは Input Manager を参照してください。 ユーザーが自由にキー設定を変更できるようにするために Input.GetAxis と Input.GetButton を 使用することをお勧めします。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { if (Input.GetKey("up")) print("up arrow key is held down"); if (Input.GetKey("down")) print("down arrow key is held down"); } }

public static bool GetKey (KeyCode key);

説明

KeyCode 列挙体パラメーターによる key によって識別されるキーを押している間、true を返します。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { if (Input.GetKey(KeyCode.UpArrow)) print("up arrow key is held down"); if (Input.GetKey(KeyCode.DownArrow)) print("down arrow key is held down"); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961