I’ve read lots about using Matrix4x4 to scale GUI elements and it has been very useful. I now have a problem where I am using Camera.WorldToScreenPoint to position a label over a “sprite” game object, but the font size appears small on mobile devices.
If I use the Matrix to scale, the font size scales well, but the location is skewed as “go.pos.x” gets adjusted by the scale (I assume?).
Is there a way to target just the font size when it comes to the scale?
void OnGUI(){
//GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3(scale.x, scale.y, 1));
GUI.skin = skin;
Level[] allLevels = FindObjectsOfType<Level>();
foreach(Level l in allLevels){
Vector3 pos = Camera.main.WorldToScreenPoint(l.transform.position);
GUI.Label (new Rect(pos.x-10, Screen.height- pos.y-15, 50,50), l.levelNum.ToString ());
}
}
Current code - matrix commented to ensure the position is fine when not scaling (it is).
Any clues?
Thanks