Best Practices for GUITexture GUIText Alignment and Sizing?

Hello All,
I’m sure this has been covered here somewhere, but I just can’t seem to find it.

Can someone show the best practices for using GUITextures and GUITexts with the different IPhone/IPad/Ipod resolutions etc? I am having trouble finding the best way to align the GUITextures on the screen so they show up on the same spot and the ~same relative size on different IOS devices. I’m using an IPod touch 4th gen for hardware but test in the older low res and IPad 4x3 res.

Once more, even if I can figure out how to properly size/place the texture, how do you align the guitext on the texture properly?

I’m sure folks have this solved already, mind sharing?

Thanks!

Hi, this is how we do it at the moment:

  1. I design everything in 960x640 (or in 1024x768 respectively, please read on).

  2. For stuff that covers the whole screen (splash screens etc.), I keep it 1024x768 with “disposable” margins, not visible when you set the player resolution to 960x640.

Transforms: 0.5, 0.5
Pixel inset values: 0, 0, 1024, 768

  1. For stuff that can remain center-locked (absolute)

Transforms: 0.5, 0.5
Pixel inset values: Modifying them for the desired placement

  1. For stuff that should be edge-locked (relative) - HUDs, counters etc.

Transforms: Modifying them for the desired placement
Pixel inset values: Not touching those

  1. For 480x320 devices, there is a global script multiplying pixel inset values by 0.5 and replacing textures with their half-res versions (optional, you can use original versions).

  2. For GUI texts, it should be pretty much similar, for 480x320 you of course need half-sized fonts.

I don’t know if this approach is the best one, but it works for me.

I hope it makes sense.

Thanks for replying!
That sounds fairly straight forward. Can you elaborate a little on your global script? What does that look like and how are you running it?

@IP tools, where can I find the script for 480x320 device (half res textures) ?

Something like that

i multiply everything by screen height divided by 320 so for retina or not it is multiplied by 2 or 1. not for ipad though

Hi i get a Null reference error trying to do this :

Where am i wrong ?

You could consider ditching use of GUI texts and work in the world coordinates of your camera. This way the positions and sizes are relative and not absolute, which leads to problems with different resolutions. See some example images here: “What is the problem?”.

If you switch to working in the world coordinates, then you can’t use GUI Text, but instead some other text way. For example, the built-in Text Mesh can be one alternative. However, like also depicted in the link above, with the TextMesh you have the issue that if you tune the character size for one certain dpi / screen resolution, it can look either jaggy or blurry in another configuration.

My Dynamic Text in Asset Store tries to be an solution for that problem. That is, you use it like Text Mesh but it’s sharp like GUIText.

Dynamic Text website has more info (e.g. interactive demo for Unity web player or a YouTube video of the demo).