I have been struggling with this for a while now. I have a UILabel that needs to take up a certain percentage of my screen. My designer is a stickler and wants the text to have margins that are uniform from device to device. To clarify, when we are using a wider screen device, I need to make the UILabel.lineWidth larger. We built our UI using a 320x480 layout (iPhone Tall 320x380 in Unity Editor game window). What I have been doing (and what works on most, but not all devices) is take the current lineWidth of 190 (which is the correct size for the 320x480 layout), and multiply it by a ratio of the difference in screen sizes and multiply by the pixel scale. So, something like this:
newWidth = oldWidth * Screen.width / 320.0f * UIRoot.GetPixelSizeAdjustment(Screen.height);
I then also adjust the local position of my UILabels parent GameObject by half of the difference between the old and new widths. My problem is that this does not work on all devices. On an iPad3, I end up with a width of 213, where I was expecting a 225. My designer mentioned that it might be pixel density that is throwing things off, but I'm wondering if aspect ratio needs to be factored in somehow. Am I missing a magic number somewhere? Any advice appreciated.