input – personalized mobile keyboard in the unit

He reads letters from Input.inputString. So, all we have to do is provide our own alternative input source.

Public class CustomInput: MonoBehaviour {

string inputThisFrame = "";

// Call this method from your buttons on the screen.
public void Type (string) {
inputThisFrame + = text;
}

// Expose the text in the same way as the entry.
public channel inputString {
get {
if (inputThisFrame! = "")
return inputThisFrame;

// return to the built-in input.
return Input.inputString;
}
}

// At the end of the frame, clear the buffer
// so we start from scratch at the next image.
void LateUpdate () {
inputThisFrame = "";
}
}

Now you can:

  1. Place an instance of CustomInput in your scene
  2. Connect your buttons to the screen to signal their input to the CustomInput instance
  3. Modify WordInput so that it takes an instance of CustomInput and asks for its inputString instead of the integrated entrance.

    The fallback that we added above ensures that the standard keyboard still works, even if it's useful, which makes testing easier.