Files
MinFt/Client/Assets/Scripts/AOTScripts/BoostrapLoading.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

95 lines
2.3 KiB
C#

using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class BoostrapLoading : MonoBehaviour
{
[SerializeField]
private TMP_Text loadingInfo;
[SerializeField]
private TMP_Text versionInfo;
[SerializeField]
private Image progressBar;
[SerializeField]
private Image subProgressBar;
[SerializeField]
private TMP_Text ProgressLabel;
[SerializeField]
private TMP_Text DownloadSize;
public void Show()
{
gameObject.SetActive(true);
}
public void Hide()
{
gameObject.SetActive(false);
}
public void SetVersionInfo(string verStr)
{
versionInfo.text = verStr;
}
public void SetProgress(float progress)
{
progressBar.fillAmount = progress;
var percent_text = (progress * 100f);
ProgressLabel.text = $"{percent_text.ToString("0.00")}%";
//bool visible = progress != 0;
bool visible = progress >= 0;
progressBar.transform.parent.gameObject.SetActive(visible);
ProgressLabel.gameObject.SetActive(visible);
}
private const double byte2mb = 1024 * 1024;
public void SetProgress(float progress, long downloadBytes, long totalBytes)
{
bool visible = progress >= 0;
progressBar.transform.parent.gameObject.SetActive(visible);
ProgressLabel.gameObject.SetActive(visible);
if(visible)
{
progressBar.fillAmount = progress;
var progressStr = $"{(downloadBytes/byte2mb).ToString("0.00")}MB/{(totalBytes/byte2mb).ToString("0.00")}MB ({(progress * 100f).ToString("0.00")}%)";
ProgressLabel.text = progressStr;
}
}
public void SetSubProgress(float progress)
{
bool visible = progress >= 0;
subProgressBar.gameObject.SetActive(visible);
if(visible)
{
subProgressBar.fillAmount = progress;
}
}
public void SetDownloadSize(long downloadBytes, long totalBytes)
{
if(downloadBytes <0 || downloadBytes == totalBytes)
DownloadSize.text = string.Empty;
else
DownloadSize.text = $"{(downloadBytes/byte2mb).ToString("0.0")}MB/{(totalBytes/byte2mb).ToString("0.0")}MB";
}
public void SetInfo(string info)
{
loadingInfo.text = info;
}
}