public static int?SetIntAndReturnPrevious(string key, int value) { int?result = null; if (UserPrefs.HasKey(key)) { result = new int?(PlayerPrefs.GetInt(key)); } UserPrefs.SetInt(key, value); return(result); }
protected virtual void CreateNewSession(DateTime toTime) { DateTime utcNow = DateTime.UtcNow; this.PreviousSessionDuration = toTime - this.StartTime; this.PauseDuration = utcNow - this.PauseTime; if (this.PreviousSessionDuration.Milliseconds < 0) { } this.StartTime = utcNow; this.PauseTime = this.StartTime; this.SessionId++; this.FirstStart = false; UserPrefs.SetDateTime("AppSession.StartTime", this.StartTime); UserPrefs.SetDateTime("AppSession.PauseTime", this.PauseTime); UserPrefs.SetInt("AppSession.SessionId", this.SessionId); UserPrefs.SaveDelayed(); }