Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity key detection

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

unity key detection

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

unity key detection


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;
}

Comment

unity detect any key

if (Input.anyKey) {
  // Code here
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# delete files older than 10 days 
Csharp :: Changing datagridview cell color dynamically 
Csharp :: c# combobox prevent typing 
Csharp :: c# writeline debug 
Csharp :: .net core temp directory 
Csharp :: how to delete all files in a directory c# 
Csharp :: c sharp split by newline 
Csharp :: C# get pc language 
Csharp :: import C++ into C# 
Csharp :: c# if file exists 
Csharp :: c# check to see if dictionary key exists 
Csharp :: unix time c# 
Csharp :: c# get current date without time 
Csharp :: unity application quit 
Csharp :: base64 to image c# 
Csharp :: c# initialize dictionary 
Csharp :: unity movetowards 
Csharp :: unity override 
Csharp :: c# cast string to double 
Csharp :: c# how to get screen resolution in class 
Csharp :: how to input a double in c# 
Csharp :: get random file in directory c# 
Csharp :: c# ip address translate localhost 
Csharp :: c# empty char 
Csharp :: c# run as administrator 
Csharp :: untiy delet ke 
Csharp :: iterate through dictionary c# 
Csharp :: disable script in unity 
Csharp :: change a dropdown to a specific option via script 
Csharp :: How can I make an action repeat every x seconds with Timer in C#? 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =