GUIText is one of Unity's legacy GUI elements, pre-4.6, so this might feel outdated, but still works.
Define your base resolution height. Say you're working with a base height of 500 pixels:
var uiBaseScreenHeight:float = 500;
Now, what happens if the Android device's screen height is, say, 1500 pixels, which is 3x larger? You'd want to increase the font size:
// Dynamically determine the UI scale to use
var uiScale:float = Screen.height / uiBaseScreenHeight; // eg 1500 / 500 = 3
// Set the base font size
var baseFontSize:int = 16;
// Set the scaled font size
var scaledFontSize:int = Mathf.RoundToInt(baseFontSize * uiScale);
// Apply the scaled font size to the GUIText element
myText.fontSize = scaledFontSize;
And if you start working with GUITextures, you can adjust the pixelInset.width and pixelInset.height properties similarly by multiplying base widths and heights against uiScale.
C# example:
public float uiBaseScreenHeight = 500f;
private voidint GetScaledFontSize (int baseFontSize) {
float uiScale = Screen.height / uiBaseScreenHeight;
int scaledFontSize = Mathf.RoundToInt(baseFontSize * uiScale);
return scaledFontSize;
}
void Start () {
My_Text_1.fontSize = GetScaledFontSize(16);
}
The other method, is to use Unity's new UI Canvas and elements instead. Right-click in your Hierarchy and choose UI > Text. This will create a Canvas with a UI.Text element. Check the Canvas' CanvasScaler component and play around with it; make it use "Scale With Screen Size" and choose your base resolution.