- Home /
Question by
Seth-McCumber · Oct 16, 2013 at 08:46 PM ·
inputcustomizationinput manager
Turn Currently Held Button Into A String(C#)
I Have Recently Started Working On Custom Input, And Am Stumped At The Beginning - How To Let The Player Change Input In Game. I Have Thought About How It Could Be Done, And This Is My Idea. To Convert The Currently Held Button To A String. Im Not Sure How This Could Be Achieved, Which Is Why Im Here. So If Anybody Knows, Or Has Any Thoughts I Would Be Glad To Help. Thanks!
-Seth
Comment
Best Answer
Answer by robertbu · Oct 16, 2013 at 08:52 PM
Two ways I can think of are to use GUI events and use Input.inputString. Input.inputString contains any characters typed during the last frame.
#pragma strict
function Update () {
if (Input.inputString.Length > 0) {
Debug.Log("Update: "+Input.inputString[0]);
}
}
function OnGUI() {
var e = Event.current;
if (e.type == EventType.KeyDown && e.character != 0) {
Debug.Log("GUI: "+e.character);
}
}
Thanks, Will Work On The Controls Now, And One $$anonymous$$ore Question, Does It Also Work For Gamepads?