Created
October 15, 2015 19:59
-
-
Save Pritesh-Patel/6ff8a8bb5a03c0eb18f5 to your computer and use it in GitHub Desktop.
Unity timer component.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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