killapp/Assets/Scripts/UI/Components/UpdateLoadingUI.cs
“虞渠成” 8568724c3f feat: 新增WiFi OTA升级功能与相关优化
1. 新增多语言文案用于OTA升级提示
2. 优化更新进度显示为整数百分比
3. 调整设备轮询间隔为5秒
4. 新增SSE流式请求处理与OTA数据模型
5. 实现WiFi环境下基于SSE的OTA升级流程
6. 增加蓝牙环境下OTA升级的前置校验与提示
2026-08-25 14:12:45 +08:00

79 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Kill.Network;
using UnityEngine;
using UnityEngine.UI;
namespace Kill.UI.Components
{
/// <summary>
/// 全局Loading组件
/// 调用 LoadingUI.Show() 显示LoadingUI.Hide() 隐藏
/// </summary>
public class UpdateLoadingUI : MonoBehaviour
{
public static UpdateLoadingUI Instance { get; private set; }
[Header("UI引用")]
public GameObject loadingPanel;
public PlayFlash loadingAni;
public Text precent;
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}
private void Start()
{
Hide();
}
/// <summary>
/// 显示Loading
/// </summary>
public void Show()
{
if (Instance == null) return;
precent.text=0+"%";
Instance.loadingPanel.SetActive(true);
if (Instance.loadingAni != null)
loadingAni.Play();
}
/// <summary>
/// 隐藏Loading
/// </summary>
public void Hide()
{
if (Instance == null) return;
if (Instance.loadingAni != null)
Instance.loadingAni.Stop();
Instance.loadingPanel.SetActive(false);
}
public void GetDownloadProcess(DownloadProgress progress)
{
Debug.Log($"下载进度: {progress.ProgressPercentage}%");
precent.text=(int)progress.ProgressPercentage+"%";
}
public void SetPrecent(float p)
{
float fullP=p*100;
precent.text=Mathf.RoundToInt(fullP).ToString()+"%";
}
}
}