Hi,
i want to make a button, with this button i want to save the time from my timer:
if (GUI.Button(new Rect(150, 10, 60, 30), "Stop")) //left down width height
{
StopMainTimer();
float elapsedTime = _mainTimer; //timePlayTime
string timeKey = Application.loadedLevelName + "_time";
if (PlayerPrefs.HasKey(timeKey))
{
float previousTime = PlayerPrefs.GetFloat(timeKey);
if (elapsedTime < previousTime)
{
PlayerPrefs.SetFloat(timeKey, elapsedTime);
}
else
{
PlayerPrefs.SetFloat(timeKey, elapsedTime);
}
print("Time: " + elapsedTime);
}
}
I do not find an error in this script, it should be print the elapsedTime, but it does not.
The MainTimer is stopping and removed from the GUI… Did i miss something here?
Also the timekey is not set in the registry.