TimeManager.cs 1001 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class TimeManager : UpdateManager
  7. {
  8. public Text timetext;
  9. public string gxlj= "HH:mm:ss";
  10. public override void updateData()
  11. {
  12. base.updateData();
  13. DateTime now = DateTime.Now; // 获取当前本地时间
  14. string dateString = now.ToString("yyyy-MM-dd"); // 格式化日期部分
  15. string timeString = now.ToString(gxlj); // 格式化时间部分
  16. string dateTimeString = dateString + " " + timeString;
  17. // Debug.Log("dateTimeString==>" + dateTimeString);
  18. timetext.text = dateTimeString.ToString();
  19. }
  20. private void OnEnable() {
  21. if(gxlj=="HH:mm")
  22. {
  23. DataManager.Instance.getInfo((msg) => {
  24. timetext.transform.parent.gameObject.SetActive( msg.general_option.update_time_display_switch==1?true:false);
  25. });
  26. }
  27. }
  28. }