My question is quite simple. Just trying to see if the mobile keyboard is covering an InputField so I can slide the canvas up a bit.
I have tried several ways to check if its covering but nothing seems to return the expected result.
I have tried:
if (TouchScreenKeyboard.area.Contains(inputfield.position))
if (TouchScreenKeyboard.area.Contains(inputfield.position, true))
if (TouchScreenKeyboard.area.Overlaps(inputfield.rect))
if (TouchScreenKeyboard.area.Overlaps(inputfield.rect, true))
I’m wondering if maybe my Canvas Scaler has anything to do with the results not being accurate.
Or is there a simpler way to have the Keyboard not cover any InputField?
Thinking out loud here without testing it. But isn’t the issue that the inputfield position and rect as in more of a world space where the keyboard area is in screen space. Try converting to screen space and see how that works.
What type of canvas? as doing Camera.main.WorldToScreenPoint for a overlay doesnt work as its not relative to a camera. for a overlay you’ll want to look at transform.TransformPoint()
Ok, I actually figured it out by using the regular RectTransform components position without any manipulations and then setting the keyboard y value to 0 this way the height is added into it and its acting as the correct position
Sorry for the really late response. I actually removed my code because I had a lot of issues getting it working so I apologize I won’t be of any help unless I try this solution again.