using UnityEngine; using System.Collections; using UnityEngine.UI; using GCGame; public class SystemOtherSetting : MonoBehaviour { // 以一定的间隔更新时间显示 public Text curTime; // 游戏左上角显示的时间,用服务器时间显示 public float updateInternal = 5.0f; // 更新间隔 private float passTime = 0.0f; // 经过时间 private void Awake() { if(updateInternal < 5.0f) { updateInternal = 5.0f; } ShowCurTime(); } public void OnBtnCaptureScreen() { StartCoroutine(CaptureScreen()); } private IEnumerator CaptureScreen() { yield return new WaitForEndOfFrame(); string fileName = System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + System.DateTime.Now.Minute.ToString() + System.DateTime.Now.Second.ToString() + ".png"; var imgBytes = ResNetwork.Instance.CaptureScreen(); ResNetwork.Instance.UploadFile(imgBytes, fileName); } private void Update() { passTime += Time.deltaTime; if(passTime > updateInternal) { passTime = 0.0f; ShowCurTime(); } } public void ShowCurTime() { curTime.text = Utils.GetServerDateTime().ToString("HH:mm"); } }