- Home /
Question by
Nivalis_Brayden · Oct 29, 2013 at 06:01 AM ·
basic programminggui-problemgui stylegui state
Timer With GUI
Hey there guys!
Still learning and I've been caught on a snag and it seems the the below code will not allow me to produce GUI and I want to see what ideas I could use, even if you throw me a few links! I basically just want the code to transfer to in game GUI to display the numbers.
public var timerTex = ""; //Text for GUI
private var levelTimer = 0.0;
private var updateTimer = false;
function Start()
{
updateTimer = true;
levelTimer = 0.0;
}
function Update()
{
if (updateTimer)
levelTimer += Time.deltaTime*1;
timerTex = levelTimer.ToString("f2"); //Time to texture with 2 decimal
}
function LevelEnded()
{
updateTimer = false;
PlayerPrefs.SetFloat("Time In Second", levelTimer ); //Keep Complete Time for compare and save
}
Thanks!
Comment
You'll probably want to add http://docs.unity3d.com/Documentation/ScriptReference/GUI.Label.html
Something like
function OnGUI () {
GUI.Label (Rect (10, 40, 50, 25),
levelTimer);
}
should do the trick (just adjust the values ..)
Ah, Thank-you very much good sir!
It had baffled me for ages.
Your answer
Follow this Question
Related Questions
GUI follow gameobject 2 Answers
gui elements to clo 1 Answer
Looking to map a GUI to a persons hand 0 Answers
How to transform GUI Texture? 1 Answer