sdgd
1
I just can’t figure it out
following
I’ve done code:
if (TimeToDisableHelp == 0 ){
GUILayout.Label("Time Help to Fade is false");
}
else if (TimeToDisableHelp < 60){
GUILayout.Label("Time Help to Fade " + (TimeToDisableHelp % 60).ToString("F0") + "s");
}
else if (TimeToDisableHelp < 3600){
GUILayout.Label("Time Help to Fade " + ((TimeToDisableHelp/60) % 60).ToString("F0") + "min " + (TimeToDisableHelp % 60).ToString("F0") + "s");
}
else if (TimeToDisableHelp < 86400){
GUILayout.Label("Time Help to Fade " + ((TimeToDisableHelp/ 3600) % 24).ToString("F0") + "Hour " + ((TimeToDisableHelp/60) % 60).ToString("F0") + "min " + (TimeToDisableHelp % 60).ToString("F0") + "s");
}
// else if (false){
// TimeToDisableHelp = String.Format ("{0:00}:{1:00}:{2:00}:{3:00}",displayDays,displayHours, displayMinutes, displaySeconds);
// }// nothing works here
TimeToDisableHelp = GUILayout.HorizontalScrollbar(TimeToDisableHelp,0.01f, 0,TimeDisableHelpSliderMax ,GUILayout.Width(50));
GUILayout.Label("Time help whole number: " + TimeToDisableHelp.ToString("F0") );
GUILayout.Label("Bunny's way " + TimeToDisableHelp.ToString("yyyy-MM-dd_HH:mm:ss") );
for my code I get depending on size of TimeToDisableHelp:
Time Help to Fade 2min 30s
Time help whole number: 90
Bunny’s way yyyy-MM-dd_HH:mm:ss // that’s all nothing changes
but if I have: 89
Time Help to Fade 1min 29s
Time help whole number: 89
but if I have: 5409
Time Help to Fade 2hours 30min 9s
Time help whole number: 5409
but if I have: 5339
Time Help to Fade 1hours 30min 59s
Time help whole number: 5339
I don’t have smallest idea what % does and how to solve this.
TonyLi
2
How about replacing all that with TimeSpan.FromSeconds().ToString()? The line below converts TimeToDisableHelp to a general-format string and assigns it to s.
string s = TimeSpan.FromSeconds(TimeToDisableHelp).ToString("");
TimeSpan reference: TimeSpan Struct (System) | Microsoft Learn
ToString() method: TimeSpan.ToString Method (System) | Microsoft Learn
String formats: Standard TimeSpan format strings | Microsoft Learn