-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClock.cs
More file actions
54 lines (45 loc) · 1.37 KB
/
Copy pathClock.cs
File metadata and controls
54 lines (45 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.UI;
public class Clock : MonoBehaviour {
public Text timerText;
private float startTime;
private string DayNight = "AM";
private bool AmPm = true; //if its true its AM if false its PM
void Start()
{
startTime = Time.time;
}
void Update()
{
float t = Time.time - startTime;
string hours = (((int)t / 60) + 11).ToString();
string mins = (t % 60).ToString("f0");
string millis = (t % 60).ToString("f2");
if (hours == "13")//changes 12 back to one after 12:59
{
hours = ((int)t / 60).ToString();
}
if (Convert.ToInt32(hours) == 12 && Convert.ToDouble(millis) == 0.00) //AM and PM system
{
if (AmPm == true)
{
AmPm = false;
DayNight = "PM";
}
else
{
AmPm = true;
DayNight = "AM";
}
}
if (Convert.ToInt32(mins) < 10)
{
timerText.text = hours + ":0" + mins + " " + DayNight;
}
else
timerText.text = hours + ":" + mins + " " + DayNight;
}
}