2025-11-03 00:24:36 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using UnityEngine.Video;
|
2025-11-12 07:04:31 +08:00
|
|
|
using Tuan.GameFramework;
|
2025-11-03 00:24:36 +08:00
|
|
|
|
2025-11-12 07:04:31 +08:00
|
|
|
namespace Tuan.GameScripts.Preload
|
2025-11-03 00:24:36 +08:00
|
|
|
{
|
2025-11-12 07:04:31 +08:00
|
|
|
public class PatchWindow : MonoBehaviour
|
2025-11-03 00:24:36 +08:00
|
|
|
{
|
2025-11-12 07:04:31 +08:00
|
|
|
public Text statusText;
|
|
|
|
|
public Slider progressBar;
|
|
|
|
|
public Text downloadSizeText;
|
|
|
|
|
public VideoPlayer video;
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
video.targetCamera = MainUICanvas.Inst.UICamera;
|
|
|
|
|
PatchEvent.OnStatusUpdate += OnStatusUpdate;
|
|
|
|
|
PatchEvent.OnProgressUpdate += OnProgressUpdate;
|
|
|
|
|
PatchEvent.OnDownloadSizeUpdate += OnDownloadSizeUpdate;
|
|
|
|
|
PatchEvent.OnClosePatchWindow += OnClosePatchWindow;
|
|
|
|
|
}
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
PatchEvent.OnStatusUpdate -= OnStatusUpdate;
|
|
|
|
|
PatchEvent.OnProgressUpdate -= OnProgressUpdate;
|
|
|
|
|
PatchEvent.OnDownloadSizeUpdate -= OnDownloadSizeUpdate;
|
|
|
|
|
}
|
2025-11-03 12:03:21 +08:00
|
|
|
|
2025-11-12 07:04:31 +08:00
|
|
|
private void OnStatusUpdate(string status)
|
|
|
|
|
{
|
|
|
|
|
if (statusText != null)
|
|
|
|
|
statusText.text = status;
|
|
|
|
|
}
|
2025-11-03 12:03:21 +08:00
|
|
|
|
2025-11-12 07:04:31 +08:00
|
|
|
private void OnProgressUpdate(float progress)
|
|
|
|
|
{
|
|
|
|
|
if (progressBar != null)
|
|
|
|
|
progressBar.value = progress;
|
|
|
|
|
}
|
2025-11-03 12:03:21 +08:00
|
|
|
|
2025-11-12 07:04:31 +08:00
|
|
|
private void OnDownloadSizeUpdate(string sizeText)
|
|
|
|
|
{
|
|
|
|
|
if (downloadSizeText != null)
|
|
|
|
|
downloadSizeText.text = sizeText;
|
|
|
|
|
}
|
|
|
|
|
private void OnClosePatchWindow()
|
|
|
|
|
{
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
}
|
2025-11-04 16:19:53 +08:00
|
|
|
}
|
2025-11-12 07:04:31 +08:00
|
|
|
}
|