Skip to content

Instantly share code, notes, and snippets.

@Pritesh-Patel
Created October 15, 2015 19:59
Show Gist options
  • Save Pritesh-Patel/6ff8a8bb5a03c0eb18f5 to your computer and use it in GitHub Desktop.
Save Pritesh-Patel/6ff8a8bb5a03c0eb18f5 to your computer and use it in GitHub Desktop.
Unity timer component.
using UnityEngine;
using System.Collections;
public class Timer : MonoBehaviour {
private bool started = false;
public float currTime = 0;
void Update () {
if (started) currTime += Time.time;
}
public void StartTimer(float startTime)
{
currTime = startTime;
started = true;
}
public void PauseTimer(bool toggle)
{
started = toggle;
}
public void ResetTimer()
{
currTime = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment