// Jimmy Vegas Unity Tutorial // These scripts will manage your lap times //LAP TIME MANAGER SCRIPT using UnityEngine.UI; public class LapTimeManager : MonoBehaviour { public static int MinuteCount; public static int SecondCount; public static float MilliCount; public static string MilliDisplay; public GameObject MinuteBox; public GameObject SecondBox; public GameObject MilliBox; void Update () { MilliCount += Time.deltaTime * 10; MilliDisplay = MilliCount.ToString ("F0"); MilliBox.GetComponent ().text = "" + MilliDisplay; if (MilliCount >= 10) { MilliCount = 0; SecondCount += 1; } if (SecondCount <= 9) { SecondBox.GetComponent ().text = "0" + SecondCount + "."; } else { SecondBox.GetComponent ().text = "" + SecondCount + "."; } if (SecondCount >= 60) { SecondCount = 0; MinuteCount += 1; } if (MinuteCount <= 9) { MinuteBox.GetComponent ().text = "0" + MinuteCount + ":"; } else { MinuteBox.GetComponent ().text = "" + MinuteCount + ":"; } } } //LAP COMPLETE SCRIPT using UnityEngine.UI; public class LapComplete : MonoBehaviour { public GameObject LapCompleteTrig; public GameObject HalfLapTrig; public GameObject MinuteDisplay; public GameObject SecondDisplay; public GameObject MilliDisplay; public GameObject LapTimeBox; void OnTriggerEnter () { if (LapTimeManager.SecondCount <= 9) { SecondDisplay.GetComponent ().text = "0" + LapTimeManager.SecondCount + "."; } else { SecondDisplay.GetComponent ().text = "" + LapTimeManager.SecondCount + "."; } if (LapTimeManager.MinuteCount <= 9) { MinuteDisplay.GetComponent ().text = "0" + LapTimeManager.MinuteCount + "."; } else { MinuteDisplay.GetComponent ().text = "" + LapTimeManager.MinuteCount + "."; } MilliDisplay.GetComponent ().text = "" + LapTimeManager.MilliCount; LapTimeManager.MinuteCount = 0; LapTimeManager.SecondCount = 0; LapTimeManager.MilliCount = 0; HalfLapTrig.SetActive (true); LapCompleteTrig.SetActive (false); } }