public void progressTimeByMinutes(float minutesToProgress) { timeMinutes += minutesToProgress; // ensure times on clock don't overrun max values while (timeMinutes >= 60) { timeMinutes -= 60; timeHours++; } if (timeHours >= 24) { isSecondDay = true; timeHours -= 24; } else if (timeHours > 12) { isSecondDay = false; } if (isSecondDay && PlayerUseItem.CurrentPhase == "Afternoon" && timeHours >= 4) { Bars.ChangePhase(); MorningScript MS = GameObject.FindGameObjectWithTag("GameManager").GetComponent <MorningScript>(); MS.bedUsed(); } else if (!isSecondDay && PlayerUseItem.CurrentPhase == "Morning" && timeHours >= 18) { PlayerUseItem.CurrentPhase = "Afternoon"; } // set clock hand rotations //RectTransform minuteHandTransform = minuteHandImage.GetComponent<RectTransform>(); //minuteHandTransform.rotation = Quaternion.Euler(new Vector3(0, 0, timeMinutes * -6f)); //RectTransform hourHandTransform = hourHandImage.GetComponent<RectTransform>(); //hourHandTransform.rotation = Quaternion.Euler(new Vector3(0, 0, (timeHours * -30f) + (timeMinutes * -0.5f))); // convert hours as minutes to strings with 2 significant figures string hoursAsString = timeHours.ToString(); if (hoursAsString.Length < 2) { hoursAsString = "0" + hoursAsString; } string minutesAsString = timeMinutes.ToString(); if (minutesAsString.Length < 2) { minutesAsString = "0" + minutesAsString; } // set UI to show time as text string timeAsString = hoursAsString + ":" + minutesAsString; timeTextbox.GetComponent <Text>().text = timeAsString; }