Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5.  
  6. public class TimeSystem : MonoBehaviour
  7. {
  8. #region Singleton
  9. public static TimeSystem Instance { get; private set; }
  10. private void InitSingleton()
  11. {
  12. Instance = this;
  13. }
  14. #endregion
  15.  
  16. private void Awake()
  17. {
  18. InitSingleton();
  19. CheckOffline();
  20. }
  21. private void CheckOffline()
  22. {
  23. TimeSpan ts;
  24. if (PlayerPrefs.HasKey("LastSession"))
  25. {
  26. ts = DateTime.Now - DateTime.Parse(PlayerPrefs.GetString("LastSession"));
  27. print(String.Format("Вы отсутствовали: {0} Дней, {1} часов, {2} минут, {3} секунд", ts.Days, ts.Hours, ts.Minutes, ts.Seconds));
  28. }
  29.  
  30. PlayerPrefs.SetString("LastSession", DateTime.Now.ToString());
  31.  
  32. }
  33.  
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement