Keyboard on Unity
Hi guys, I'm developing a game for mobile platform, where the key is the keyboard. I can't use the native keyboard of android o ios, because i need to real time keyboard. I have developed two solution for my problem, the first use the EventSystem of unity, in particular use the Button script, where I connect the onClick method of Button, that is the simply solution. In the second solution i use the Update method with Input.touch functionality and I write this: void Update () {
var touchPos = Input.mousePosition;
if (Input.GetMouseButtonDown((0)))
{
if (touchPos.x < _position.x + (_size.x / 2) &&
touchPos.x > _position.x - (_size.x / 2))
if (touchPos.y < _position.y + (_size.y / 2) &&
touchPos.y > _position.y - (_size.y / 2))
Debug.Log("Pressed: " + gameObject.name);
}
}
N.B. The _size variable is the size of image of button, and position is the position of rect transform of button.
This snippet of code work more faster than my first solution. But i think the first and second solution aren't indipendent from frame. I need to create a keyboard, with the smallest input lag. What can I do? Thanks in advance.
Your answer
Follow this Question
Related Questions
PointerEventData.hovered blank when used with Right mouse button drag. 0 Answers
Why is my IOS tap function is not working? 0 Answers
UnityEngine.UI and UnityEngine.EventSystem do not work, what do I do? 1 Answer
what is the code to do somthing whan the user sliding the screen? 2 Answers
how to do on single click fire and on drag appears the joystick and get the input from joystick 0 Answers