void OnTriggerEnter2D(Collider2D other) { if (ArcadePhysics.SameWorld(this, other)) { // only trigger if this component is on if (enabled) { // and now it's time to stop the level FinalizeLevel.CrossFinishLine(clock.GetTime()); } } }
void Update() { // what time is it? float time = clock.GetTime(); // convert to text string int mins = (int)(time / 60); int secs = ((int)time) % 60; int msec = (int)(10 * (time - mins * 60 - secs)); string text = string.Format("{0:00}:{1:00}.{2:0}", mins, secs, msec); // lazy refresh text in label (only when changed) if (label.text != text) { label.text = text; } }