“Deteksi Kunci Persatuan” Kode Jawaban

Deteksi Kunci Persatuan

if (Input.GetKeyDown(KeyCode.Space))
        {
            print("space key was pressed");
        }
RyanGar46

Jika dapatkan Key Down Unity

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown("space"))
        {
            print("space key was pressed");
        }
    }
}
Xenophobic Xenomorph

Deteksi Kunci Persatuan

    void Update()
    {
        if (Input.GetKeyDown("space"))
        {
            print("space key was pressed");
        }
    }
Depressed Dugong

Deteksi Kunci Persatuan


public static bool GetAlphaKeyValue(out int alphaKey)
{
    alphaKey = -1;

    if (Input.GetKeyDown(KeyCode.Alpha0) alphaKey = 0;
    else if (Input.GetKeyDown(KeyCode.Alpha1) alphaKey = 1;
    else if (Input.GetKeyDown(KeyCode.Alpha2) alphaKey = 2;
    else if (Input.GetKeyDown(KeyCode.Alpha3) alphaKey = 3;
    else if (Input.GetKeyDown(KeyCode.Alpha4) alphaKey = 4;
    else if (Input.GetKeyDown(KeyCode.Alpha5) alphaKey = 5;
    else if (Input.GetKeyDown(KeyCode.Alpha6) alphaKey = 6;
    else if (Input.GetKeyDown(KeyCode.Alpha7) alphaKey = 7;
    else if (Input.GetKeyDown(KeyCode.Alpha8) alphaKey = 8;
    else if (Input.GetKeyDown(KeyCode.Alpha9) alphaKey = 9;

    return alphaKey >= 0;
}

Elegant Echidna

Jawaban yang mirip dengan “Deteksi Kunci Persatuan”

Pertanyaan yang mirip dengan “Deteksi Kunci Persatuan”

Lebih banyak jawaban terkait untuk “Deteksi Kunci Persatuan” di C#

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya