- Home /
how do i change text size?
I need a better version of this code or simply for the text to change size, font, color easier etcenter code here
var originalWidth = 1366.0; // define here the original resolution
var originalHeight = 768.0; // you used to create the GUI contents
private var scale: Vector3;
function OnGUI(){`enter code here`
scale.x = Screen.width/originalWidth; // calculate hor scale
scale.y = Screen.height/originalHeight; // calculate vert scale
scale.z = 1;
var svMat = GUI.matrix; // save current matrix
// substitute matrix - only scale is altered from standard
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);
// draw your GUI controls here:
GUI.contentColor = Color.yellow;
GUI.Box(Rect(10,10,200,55), "Lawrence Mercieca's game test \n \n(PRE ALPHA TESTING PHASE)");
GUI.Button(Rect(20, 680, 50, 30),bulletcount+" / "+magcount);
if (rtext){
GUI.Button(Rect(20, 720, 100, 30), "RELOADING");
//...
// restore matrix before returning
GUI.matrix = svMat; // restore matrix
}
}
So this scaling method doesn't properly affect your font sizes so they scale in concert with everything else? I would've told you it does - please confirm for me/us that it doesn't?
I don't recall - must font sizes be integers? Even if so, the methodology is the same, except you'll round to the nearest integer. You'll measure the discrepancy between the original size and the scaled size, and use that value to change the point size of the font.
So it'll be originalFontSize * scaleDiscrepancy
Your answer
Follow this Question
Related Questions
GUIText Help 1 Answer
Relate font size to screen size in GUISkin 2 Answers
Changing 3d text through script 1 Answer
Mario style gui! 1 Answer