Hello! I am very new to Unity and C#. I’ve been getting a reference error in my console and I’m very confused on what to do. Here’s my code for the timer:
using System.Collections;
using UnityEngine.UI;
using UnityEngine;
public class Timer : MonoBehaviour {
public Text timerText;
private float startTime;
private object timer;
// Use this for initialization
void Start () {
startTime = Time.time;
}
// Update is called once per frame
void Update () {
float t = Time.time - startTime;
string minutes = ((int)t / 60).ToString();
string seconds = (t % 60).ToString("f2");
timer.text = minutes + ":" + seconds;
}
}