you can, it just involves a bit of mathematics with two Rect(s).
The way to check if two Rect(s) intersect is here (follow the Algorithm, its in C++ so don’t bother with Copying and pasting).
Custom Keyboard
As for the custom keyboard if your bent on making one, as I said its easy but kinda repetitive. Basically they I’d have it is to set up pages of Buttons. so you get your lower case, upper case symbols and numbers and whatever.
First Create a Panel name it keyboard ,and size it to your keyboard size, then create yet another panel , make it the parent of Keyboard and name it LowerCaseAlpha. Make these a Prefab and store in Resources Somewhere, this way you can call upon it anywhere in the game if for some reason it has been deleted from your scene.
Now create a bunch of buttons for your lower case, be sure to add a SHIFT button, A DONE or ENTER Button, A BACKSPACE button and a Symbol access button(on some keyboard sit looks like ±?!).
Repeat for the other pages as needed.
Now got to your keyboard object and create a Script called Onscreen Keyboard.
Now make a string variable for your text input, and maybe an UI reference variable called textOBject for what to send the text to.
Make a public function that has a string parameter and call it CharInput, this will appended you input to the end of the input string. if you want you have send the input string now to the InputField of you want to see it update as they type. Basically when you clisk a button, add a OnClick Receiver for it that and add your corresponding character to it.
public void CharInput(string myChar) {
inputText += myChar;
}
Next , we need to add a backspace Event so your user can actually delete things. just make a public function That Shortens the string
public void Backspace() {
inputText = inputText.Remove(inputText.Length - 1);
}
Next is our Done or Accept Button. We just send off our input string to out InputField and we can either Hide or Destroy
public void AcceptInput(bool destroy = false) {
textObject.text = inputText;
//Null it for our next input if we don't destory
inputText = null;
if(destroy) {
Destroy(gameObject);
}
else {
gameObject.active = false;
}
}
Next is our Shift/Symbol Button, there alot of way to do this , the best is to keep all but the active pages hidden, and select them by deactivating all children then activate the one you want.
public void SelectPage(int index) {
//INDEX is the index child of the keyboard,
//keep in mind of this when changing the order of pages
for(int i = 0; i < transform.childCount; i++) {
var page = transform.GetChild(i)
page.gameObject.enabled = false
//activate of index matches
if(i == index) {
page.gameObject.enabled = true;
}
}
}
Now on eachButton Create/Add a script tht will send you corresponding event and your pretty much done
Hope it helps