- Home /
Detect device and adjust screen
Hello everybody,
I found myself in a situation where my game does not accurately fit into the screen on all devices (specifically, Desktop + iPhone + iPad but I am guessing the situation with Android is much more segmented).
So, my first hunch was to do a device testing function, and adjust the distance of the camera accordingly (this is a fixed-position camera, looking at the game field).
While trying to answer my own question, I found these links on the subject:
iPhone.generation - detect device + generation. Problematic solution, new devices will be left out.
SystemInfo.deviceType - only helps in differentiating between Handheld / Desktop
Application.platform - same problem as above, differentiate between iPhone player and desktop.
Platform Dependent Compilation - compile time directives, same problem.
My questions are:
Is this the correct approach? Should I use device detection or screen size detection?
Did I miss any function that lets me simply ask "Is this an iPhone of ANY generation?" or "Is this an IPad of any generation?"
Thanks in advance.
Answer by JCprogrammer · Feb 26, 2013 at 08:09 PM
I think this can be solved by Manipulating Camera Aspects Manually . i faced this problem too, and i fixed it by an script which could Set the Appropriate Aspect for each device . you need to just change these values i think :
1 - Camera.main.aspect = (Screen.currentResolution.width / Screen.currentResolution.height);
just this simple piece of code helped me fit each of my game scenes for any Android devices .
Answer by shubhamgarg1234 · Jun 29, 2012 at 12:17 PM
I think you should go for screen size detection, because a device can have different resolution. So you have to generalize your code according to your screen and current resolution and also adjust your camera accordingly.