RB.InputString
Method - Static
public static string InputString()
|
Parameters
No parameters.
Returns
string
Character string
DescriptionReturns a string of characters entered since last IRetroBlitGame.Update call. Normally this string will be 0 or 1 characters long, but it is possible that the user may quickly perform two key strokes within the spawn of a single game loop. This method is the preferred way of capturing user text input. Examplestring userInput = "";
void Update() { string input = RB.InputString();
for (int i = 0; i < input.Length; i++) { char c = input[i];
if (c >= ' ') { userInput.Append(c); } else if (c == (char)UnityEngine.KeyCode.Backspace && userInput.Length > 0) { userInput.Truncate(userInput.Length - 1); } else if (c == (char)KeyCode.Return) { Execute(userInput) } } } |
See AlsoRB.KeyPressed RB.KeyReleased RB.KeyDownSee DocsFeatures - Keyboard |