Hello everyone,
if((Input.GetTouch(i).position.x > 1000)&&(Input.GetTouch(i).position.x < 1280)
{
}
I have placed touch controls of my game by using such touch position codes like you see above. I use this touch position code with 1280x800 resolution. I want to use this with all resolutions. I know a long way which is reading screen height and screen width on screen load and changing X or Y touch positions according to it by float values, but i thought that there must be a short way. I think i should use WorldScreenToPoint. But i don’t know how to integrate it. How can i use this with all resolutions?
I’d say the “short way” is not using positions that you’re explicitly defining in this manner at all, but rather relying on the graphics raycaster for UI elements and a normal raycast with ScreenToWorldPoint() on contact with any non-UI parts of the screen.
Barring that, the “long way” using screen width and height is the only way, because you’re defining areas that have no solid correlations in the game world and Unity isn’t psychic. If you want something to mean “an area between 80% to 90% of the screen width and 60% to 70% of the screen height”, you’ll need to tell it that. However, what if the user rotates the view around to landscape instead of portrait?
Honestly, I would define everything you need as UI elements in the canvas system and let the system help you to do whatever it is you need to do.
1 Like
This sounds good i think i am going to work on it. Thanks for the advice.
There is only one rotation because of that, user can’t do that. 
This also sounds good, i can try that i can’t find a solution.
Thank you!