Hello everyone, I wrote a keyboard simulator for Android in Unity3D, it is not very sharpened
for special children , and is intended for a wide user
(well, I think so) . And in this post I want to talk about the problem of overlapping part of the screen with a keyboard and how to solve it.

A little about the game
Although this is not related to the topic of the post, I will tell you a little about the game:
The principle is simple, you choose one of the proposed texts or enter your own and begin to practice typing. When you press the right button in the letter the ball flies. If you are mistaken, the green veil is released and does not rise until you erase the excess.
')
I was asked by the teachers to make this game, since the popular simulators are very sharpened for the speed of the print and are very sharpened for the speed and correct placement of the fingers. This is not very suitable for practicing special people, so. how can I type with only two fingers (the rest do not unbend), and my girlfriend does not even have a foot. On the speed of printing generally keep quiet. So I'm not trying to beat the guys with klava.org or clavagonki, but I write my own.

Work with input
I decided to work with text input through the standard Unity UI InputField, the button press event and the last character is obtained as follows.
InputField field; public void Start() { field = GetComponent<InputField> (); field.onValueChange.AddListener (delegate {ValueChangeCheck ();});
Then comes the boring magic of throwing balls into letters, I will not publish it, because
there is a lot of govnokod there, it requires refactoring.
Problem
On the computer, everything worked perfectly, but when I launched the game on Android, I saw the
Austerlitz Endless Sky , the keyboard ran over the main game space and blocked everything.

I didn’t find anything good in Google (perhaps I don’t know how to google) and I began to pick the properties of the camera myself.
Solution to the problem
In the settings I found the Viewport Rect property and set it to Y at 0.5, I thought that this was the end of my problems, but no.

In the vertical orientation of the screen, the keyboard ceased to run into the screen, but in the horizontal keyboard still ran into the picture, then I played around with numbers and picked up the value for the horizontal, 0.3. And rightly so, everything left in the vertical.
Thinking, I realized that the ratio of the height of the keyboard to the height of the screen. I decided to write a script that changes this coefficient, calculated from the current keyboard height. I found on stackoverflow a height getting script and wrote the following script:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class CameraController : MonoBehaviour { Camera cam;
Everything worked fine judging by the Profiler'u without losing FPS.
→ The game can be downloaded
here.→ My website:
aacidov.ru