Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class KeepTrackOfTime : Monobehavior
- {
- private float seconds;
- private float hours;
- private float minutes;
- private float minutesInSeconds;
- private float hoursInSeconds;
- private float secondsInSeconds; //don't really need this.
- private float totalSeconds;
- private float startTimeInSeconds;
- void Start()
- {
- //----------------------------------------
- //USER INPUTS
- //----------------------------------------
- hours = 2;
- minutes = 10;
- seconds = 29;
- //----------------------------------------
- //DO CONVERSIONS -
- //----------------------------------------
- if (hours > 0){hoursInSeconds = 3600 * hours;}else { hoursInSeconds = 0; }
- if (minutes > 0) { minutesInSeconds = 60 * minutes; } else { minutesInSeconds = 0; }
- secondsInSeconds = seconds;
- //Add up the total seconds
- totalSeconds = hoursInSeconds + minutesInSeconds + secondsInSeconds;
- Debug.Log("----------------------------------------");
- }
- void Update()
- {
- //Count down the timer---- This will be the textfield for timer.
- totalSeconds -= 1 * Time.deltaTime;
- Debug.Log("----------------------------------------------");
- Debug.Log("Current time: " + totalSeconds.ToString("0"));
- }
- }
Add Comment
Please, Sign In to add comment