dimanche 4 mars 2018

Uniy - Call Keyboard Input from a script?

I'll try to explain this the best I can. Let's say I have 2 if statements that both send a Debug.Log message to console, like this:

if(Input.GetKeyDown("c")){
    Debug.Log("C was pressed!");
}

if(Input.GetKeyDown("b")){
    Debug.Log("b was pressed!");
}

We of course know that we'll get these messages when we press the appropriate keys. But what if I want to get another script to trigger these if statements instead of the keyboard doing it?

If I have a list of if statements that are taking in a keyboard input like these ones, is there a way to trigger these if statements through code or would I have to change the condition?

Aucun commentaire:

Enregistrer un commentaire