Init
This commit is contained in:
51
Assets/GameScripts/Preload/PatchWindow.cs
Normal file
51
Assets/GameScripts/Preload/PatchWindow.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Video;
|
||||
using Tuan.GameFramework;
|
||||
|
||||
namespace Tuan.GameScripts.Preload
|
||||
{
|
||||
public class PatchWindow : MonoBehaviour
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
private void OnStatusUpdate(string status)
|
||||
{
|
||||
if (statusText != null)
|
||||
statusText.text = status;
|
||||
}
|
||||
|
||||
private void OnProgressUpdate(float progress)
|
||||
{
|
||||
if (progressBar != null)
|
||||
progressBar.value = progress;
|
||||
}
|
||||
|
||||
private void OnDownloadSizeUpdate(string sizeText)
|
||||
{
|
||||
if (downloadSizeText != null)
|
||||
downloadSizeText.text = sizeText;
|
||||
}
|
||||
private void OnClosePatchWindow()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user