123456789101112131415161718192021222324252627282930313233343536 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- namespace ET
- {
- public class CheckResUpdate : MonoBehaviour
- {
- void Start()
- {
- var progress = this.gameObject.transform.Find("Img_bar").gameObject.GetComponent<Image>();
- var txtProgress = this.gameObject.transform.Find("Text_progress").gameObject.GetComponent<Text>();
- YooAssetProxy.InitHostCallbacks((onStateChanged) =>
- {
- txtProgress.text = onStateChanged.CurrentStates.ToString();
- if (onStateChanged.CurrentStates == EPatchStates.PatchDone)
- {
- txtProgress.text = "资源下载完毕,正在加载核心逻辑。。。";
- }
- }, (onProcessUpdated) =>
- {
- string currentSizeMB = (onProcessUpdated.CurrentDownloadSizeBytes / 1048576f).ToString("f1");
- string totalSizeMB = (onProcessUpdated.TotalDownloadSizeBytes / 1048576f).ToString("f1");
- string text =
- $"资源下载中:{onProcessUpdated.CurrentDownloadCount}/{onProcessUpdated.TotalDownloadCount} {currentSizeMB}MB/{totalSizeMB}MB";
- txtProgress.text = text;
- progress.fillAmount = onProcessUpdated.CurrentDownloadSizeBytes * 1.0f /
- onProcessUpdated.TotalDownloadSizeBytes;
- });
- }
- }
- }
|