There was a problem with saving the date. I generate a date by adding two minutes to the current date and time. after restarting the program, the date is not saved.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; public class NewBehaviourScript : MonoBehaviour { public Text timenow; public Text time; public DateTime timerSob; private Save da = new Save(); private void Awake() { if (PlayerPrefs.HasKey("da")) { da = JsonUtility.FromJson<Save>(PlayerPrefs.GetString("da")); timerSob = da.timerSob; } } void Update() { timenow.text = Convert.ToString(DateTime.Now); time.text = Convert.ToString(timerSob); } public void timer() { timerSob = DateTime.Now.AddMinutes(2); } #if UNITY_ANDROID && !UNITY_EDITOR //ПРОЦЕСС СОХРАНЕНИЯ ДАННЫХ ИГРЫ private void OnApplicationPause(bool pause) { if (pause) { PlayerPrefs.SetString("da", JsonUtility.ToJson(da)); da.timerSob = timerSob; } } #else private void OnApplicationQuit() { da.timerSob = timerSob; PlayerPrefs.SetString("da", JsonUtility.ToJson(da)); } #endif [System.Serializable] public class Save { public System.DateTime timerSob; } } 