void Start() { UpdateStartTime((int startTime) => { D.Log("最新时间戳: " + startTime + " => " + HS_Time.ConvertToTimePoint(startTime)); }); }
void Update() { if (Input.GetKeyDown(KeyCode.Keypad0)) { int t = StartTime + (int)UnityEngine.Time.realtimeSinceStartup; D.Log(HS_Time.ConvertToTimePoint(t)); } }
IEnumerator Time(System.Action <int> action) { WWW w = new WWW("http://www.baidu.com/"); yield return(w); if (!string.IsNullOrEmpty(w.error)) { D.LogError("获取时间错误"); yield return(true); } string date = w.responseHeaders["DATE"]; DateTime t; if (DateTime.TryParse(date, out t)) { StartTime = HS_Time.ConvertDateTimeInt(t); if (action != null) { action(StartTime); } } }