PhotonNetwork.time
Hello im using the PhotonNetwork.time to sync the time for all players in my room but my problem is that i want make it to minutes and seconds and the seconds should have 2 digits.
but currently the PhotonNetwork.time uses double as digit.
how can i show only 2 digits of the seconds like Time.deltatime
but currently the PhotonNetwork.time uses double as digit.
how can i show only 2 digits of the seconds like Time.deltatime
0
Comments
-
This will help you
/// /// The time that should be formatted
/// This returns a formatted string showing the time
///
///
public void SetTimeLeftString (double timePassed)
{
double timeLeft = GameSetup.TimeLimit - timePassed;
int minutesLeft = Mathf.FloorToInt ((float)timeLeft / 60);
int secondsLeft = Mathf.FloorToInt ((float)timeLeft) % 60;
minutesLeft = (minutesLeft >= 0 ? minutesLeft : 0);
secondsLeft = (secondsLeft >= 0 ? secondsLeft : 0);
TimeLeftString = minutesLeft.ToString () + ":" + secondsLeft.ToString ("00");
}0 -
how GameSetup.TimeLimit - timePassed ?
0 -
Hi,
I would suggest you use c# own timespan system and work with it, it will give you the whole set of api to query time.
https://www.dotnetperls.com/timespan
https://msdn.microsoft.com/en-us/library/system.timespan.fromseconds(v=vs.110).aspx
Then you can parse as xx.ToString ("00") from timespan values.
Bye,
Jean0