using UnityEngine;
public class MyCounter : MonoBehaviour
{
public int count;
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
++count;
}
switch (count)
{
case 1:
Debug.Log("1st time!");
break;
case 2:
Debug.Log("2nd time!!");
break;
case 3:
Debug.Log("3rd time!!!");
break;
}
}
}
you’ll need to add a couple of things to @ung 's example to get the time element:
a variable to store the start time of the “minute” when count =0, and check to see if the current time is greater than startTime + 1 at which point reset the count to 0.
using UnityEngine;
public class MyCounter : MonoBehaviour
{
public int count;
private float t;
private void Update()
{
t += Time.deltaTime;
if (t >= 60)
{
count = 0;
t -= 60;
}
if (Input.GetKeyDown(KeyCode.Space))
{
++count;
}
switch (count)
{
case 1:
Debug.Log("1st time!");
break;
case 2:
Debug.Log("2nd time!!");
break;
case 3:
Debug.Log("3rd time!!!");
break;
}
}
}