- Home /
Question by
valtteri_m · Aug 25, 2014 at 04:15 PM ·
javascriptguiguitextintguilabel
GUI Text to GUI Label Script?
How do I change this into a GUI Label?
var curHealth : int = 100;
var healthtext : GUIText;
function Update ()
{
healthtext.text = curHealth + " ";
}
Comment
Best Answer
Answer by Landern · Aug 25, 2014 at 04:18 PM
var curHealth : int = 100;
function OnGUI() {
GUI.Label(Rect(10, 10, 100, 20), curHealth.ToString() + " ");
}
will this work once I do that?
if(curHealth > 100) {
curHealth = 100;
Using ToString in curHealth.ToString() + " "
is unnecessary, but adding a space to convert an int to a string is not good form, so ideally it would be curHealth.ToString()
.
Your answer
Follow this Question
Related Questions
Arrange ints from biggest to smallest and display them in a table 1 Answer
OnGui doesn't work 2 Answers
Setting Scroll View Width GUILayout 1 Answer
changing font + size of text 1 Answer