- Home /
GUI Text Variable Counter In C#
Hi Guys :) I have a Small Question. I am Currently Making a MMORPG (that works right now) and now i need a Variable Counter In C# (Not JavaScript Because i already know it) Can Someone Help me :)?
-Yohan
Why bold? Not too easy on the eyes ...
What do you mean by a 'variable counter'? An incrementing time display? A display of the total number of players? A health display? A counter which shows the current number of variables in use (probably not :D)? This is a very ambiguous question.
I'll tell you now, because you'll get burned by other people. Unity doesn't use Javascript. It uses Unityscript. The two are very different from each other.
Ok xD. I need a GUIText that Counts the Current Health. Any Ideas? xD
Answer by Kleptomaniac · Apr 21, 2012 at 02:31 PM
Well, that totally depends on what current health system you have! But generally, assuming you already do have some manner of health system set up, the C# method is pretty much exactly the same as the JS method. Like so:
GUIText healthGUI;
void Update () {
healthGUI.text = yourHealthVar.ToString();
}
Hope that helps, Klep
Haha, no worries. If that helped you, acknowledge by accepting my answer (ticking it). Otherwise, glad I could help. :P
Emm One Question. What Shall i do if i do it in a 3D Text? But Still thanks for the Health GUIText ;)
For a text mesh, same principles apply:
Text$$anonymous$$esh healthGUI;
void Update () {
healthGUI.text = yourHealthVar.ToString();
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Renderer on object disabled after level reload 1 Answer