- Home /
Question by
imnickb · Apr 14, 2013 at 08:14 PM ·
uiiosresolutiondevicedimensions
Identifying iphone resolution isn't working for all devices
I'm working on a mac but I'm developing for iOS. I've got the iOS add on and I'm switching the resolution in the resolution drop down box. I'm just trying to move a UI element to look good on all resolutions. I've cased out the resolutions in script and for some resolutions it's working but other resolutions are not returning the correct dimensions. Any help would be appreciated!
I'm casing things out according to height and width instead of using the device type since the device type doesn't return what I want when using the editor. Let me know if I'm way off base here. Thanks!
function Start ()
{
//iPhone & iPhone3G & iPhone3GS - Wide
if (Screen.width == 480 && Screen.height == 320)
{
print("iPhone & iPhone3G & iPhone3GS - Wide" + Screen.height);
transform.position = Vector3(-1.45, .8, 0);
}
//iPhone4 & iPhone4S - Wide
if (Screen.width == 960 && Screen.height == 640)
{
print("iPhone4 & iPhone4S - Wide" + Screen.height);
transform.position = Vector3(-1.45, .8, 0);
}
//iPhone 5 - Wide
if (Screen.width == 1136 && Screen.height == 640)
{
print("iPhone5 - Wide" + Screen.height);
transform.position = Vector3(-1.3, .8, 0);
}
//iPad & iPad2 & iPad mini - Wide
if (Screen.width == 1024 && Screen.height == 768)
{
print("iPad & iPad2 & iPad mini - Wide" + Screen.height);
transform.position = Vector3(-1.3, .8, 0);
}
//iPad3 - Wide
if (Screen.width == 2048 && Screen.height == 1536)
{
print("iPad3 - Wide" + Screen.height);
transform.position = Vector3(-1.75, .8, 0);
}
else
{
print(Screen.height);
transform.position = Vector3(-1.45, .8, 0);
}
}
Comment
Answer by corrivai · Oct 08, 2018 at 07:56 AM
Ok, the thread is very old, but the solution is:
/iPhone & iPhone3G & iPhone3GS - Wide
if (Screen.width == 480 && Screen.height == 320)
{
print("iPhone & iPhone3G & iPhone3GS - Wide" + Screen.height);
transform.position = Vector3(-1.45, .8, 0);
}
else if (Screen.width == 960 && Screen.height == 640) //iPhone4 & iPhone4S - Wide
{
print("iPhone4 & iPhone4S - Wide" + Screen.height);
transform.position = Vector3(-1.45, .8, 0);
}
:)
Your answer
![](https://koobas.hobune.stream/wayback/20220613100323im_/https://answers.unity.com/themes/thub/images/avi.jpg)