I need to put all of my code in the start function but I am getting an error : CS1525 symbol private . When I put the code in the start function the error came up at the bottom. Here is my code :
public class MyClock : MonoBehaviour
{
public int Minutes = 0;
public int Seconds = 0;
private Text m_text;
private float m_leftTime;
private void Start()
{
m_text = GetComponent<Text>();
m_leftTime = GetInitialTime();
if (m_leftTime > 0f)
{
// Update countdown clock
m_leftTime -= Time.deltaTime;
Minutes = GetLeftMinutes();
Seconds = GetLeftSeconds();
// Show current clock
if (m_leftTime > 0f)
{
m_text.text = "Time : " + Minutes + ":" + Seconds.ToString("00");
}
else
{
// The countdown clock has finished
m_text.text = "Time : 0:00";
}
}
private float GetInitialTime()
{
return Minutes * 60f + Seconds;
}
private int GetLeftMinutes()
{
return Mathf.FloorToInt(m_leftTime / 60f);
}
private int GetLeftSeconds()
{
return Mathf.FloorToInt(m_leftTime % 60f);
}
}