unity3d - How to make stopwatch in unity (c#) -
this question has answer here:
- how make script wait/sleep in simple way in unity 2 answers
- unity - pass data between scenes 2 answers
- what best way save game state? 1 answer
hello don't know how make stopwatch in unity. make stopwatch count on scene(on top), show time in other scene(win scene) , save best result. stopwatch should start when load scene(on start method) , end when object collides collider. can me out?
public text timertext; private float starttime; private bool finnished = false; // use initialization void start () { starttime = time.time; } // update called once per frame void update () { float t = time.time - starttime; string minutes = ((int)t / 60).tostring (); string seconds = (t % 60).tostring("f1"); timertext.text = minutes + ":" + seconds; } }
so made stopwatch (timer counts upwards). don't know how stop stopwatch when collides collider , present time in next scene.
Comments
Post a Comment