Question by
Alaviivamies · Nov 30, 2017 at 04:27 PM ·
javascripttextscaling
How to make text bigger in javascript code?
I'm trying to make an item counter for my little game but the text is so small compared to the timer I have. The font size of my timer is 20. How can I make my item counter text bigger? I used this video for the codes https://www.youtube.com/watch?v=cg349rLy8Ro
static var gscore : int = 0;
function OnGUI() {
GUI.Label (Rect (10, 10, 100, 20), ("Esineet: " + gscore));
}
function OnTriggerEnter (info : Collider) {
Destroy(gameObject);
ScoreCount.gscore += 1;
}
Comment
Since about Unity 4.6, there's a new UI system. You might want to try it since it's easier to design: https://unity3d.com/learn/tutorials/topics/user-interface-ui/ui-text?playlist=17111
Best Answer
Answer by FadiLoutf · Nov 30, 2017 at 08:19 PM
Try this :
function OnGUI()
{
var myStyle : GUIStyle = new GUIStyle(GUI.skin.label);
myStyle.fontSize = 30;
myStyle.normal.textColor = Color.yellow;
GUI.Label(new Rect(10, 10, 150, 50), "Score: ", myStyle);
}
Your answer
Follow this Question
Related Questions
Show in text certain variables 0 Answers
Unity 5.0.2 UI Text - Best Fit isn't working correctly? 1 Answer
Writing save files (JavaScript) 0 Answers
Spawn a dot for every number typed? 0 Answers