Answer the question
In order to leave comments, you need to log in
Resize/rescale text in unity 5?
Good day.
There is an account output in the center of the screen:
void OnGUI()
{
GUI.Label(new Rect(width*0.5f-50, 0, 100, 30), scores.score.ToString(), myStyle);
}
public class Score1 : MonoBehaviour {
public ElipsController scores;
public GUIStyle myStyle;
float width;
void Update()
{
width = Screen.width;
}
public static void AutoResize(int screenWidth, int screenHeight)
{
Vector2 resizeRatio = new Vector2((float)Screen.width / screenWidth, (float)Screen.height / screenHeight);
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(resizeRatio.x, resizeRatio.y, 1.0f));
}
void OnGUI()
{
AutoResize(1024,768);
GUI.Label(new Rect(width*0.5f-50, 0, 100, 30), scores.score.ToString(), myStyle);
}
}
Answer the question
In order to leave comments, you need to log in
The unit has had a normal UI for two years already, which can scale depending on the screen size, with it this task is solved in an elementary way: Designing UI for Multiple Resolutions
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question