2025-03-10 07:25:29 +00:00
|
|
|
using System.Collections.Generic;
|
2025-03-04 07:30:03 +00:00
|
|
|
using TMPro;
|
2024-12-15 01:39:39 +00:00
|
|
|
using UnityEngine;
|
2025-03-06 02:40:36 +00:00
|
|
|
using UnityEngine.AddressableAssets;
|
|
|
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using Random = UnityEngine.Random;
|
2024-12-15 01:39:39 +00:00
|
|
|
|
|
|
|
|
public class LoadingUI : MyCoroutine
|
|
|
|
|
{
|
2025-03-26 00:49:56 +00:00
|
|
|
public static bool isIns;
|
2024-12-15 01:39:39 +00:00
|
|
|
public static LoadingUI Ins;
|
|
|
|
|
public GameObject go;
|
2025-03-06 02:40:36 +00:00
|
|
|
public TextMeshProUGUI[] texts; // 0 팁, 1 로딩 진행 상황
|
|
|
|
|
public Slider slider_loading;
|
|
|
|
|
|
|
|
|
|
public RawImage loadingimg;
|
|
|
|
|
AsyncOperationHandle<Texture> currentHandle;
|
2025-03-10 07:25:29 +00:00
|
|
|
List<bool> list_loadingComplete = new List<bool> { false, false };
|
2025-03-06 02:40:36 +00:00
|
|
|
|
|
|
|
|
public int MaxImage = 1;
|
|
|
|
|
int m_index = 1;
|
2024-12-15 01:39:39 +00:00
|
|
|
|
2025-03-26 00:49:56 +00:00
|
|
|
void Awake() { Ins = this; isIns = true; }
|
2025-03-04 07:30:03 +00:00
|
|
|
|
2025-03-11 23:47:21 +00:00
|
|
|
private void Start() { Load_Img(); }
|
|
|
|
|
|
|
|
|
|
void Load_Img()
|
2024-12-15 01:39:39 +00:00
|
|
|
{
|
2025-03-06 02:40:36 +00:00
|
|
|
m_index = Random.Range(1, MaxImage + 1);
|
|
|
|
|
AddrResourceMgr.Ins.LoadObject<Texture>($"Assets/Res_Addr/Loading/Loading{m_index}.jpg", handle =>
|
|
|
|
|
{
|
|
|
|
|
if (currentHandle.IsValid())
|
|
|
|
|
{
|
|
|
|
|
Addressables.Release(currentHandle);
|
|
|
|
|
loadingimg.texture = null; // 기존 Texture 참조 해제
|
|
|
|
|
}
|
2024-12-15 01:39:39 +00:00
|
|
|
|
2025-03-06 02:40:36 +00:00
|
|
|
currentHandle = handle;
|
|
|
|
|
loadingimg.texture = handle.Result;
|
|
|
|
|
});
|
2025-03-11 23:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Start_Loading()
|
|
|
|
|
{
|
|
|
|
|
go.SetActive(true);
|
|
|
|
|
texts[0].text = "팁 입니다.";
|
|
|
|
|
slider_loading.value = 0f;
|
|
|
|
|
texts[1].text = "0%";
|
2025-03-10 07:25:29 +00:00
|
|
|
|
|
|
|
|
for (int i = 0; i < list_loadingComplete.Count; i++)
|
|
|
|
|
list_loadingComplete[i] = false;
|
2025-03-06 02:40:36 +00:00
|
|
|
}
|
|
|
|
|
public void Set_LoadingSlider(float proc)
|
2024-12-15 01:39:39 +00:00
|
|
|
{
|
2025-03-06 02:40:36 +00:00
|
|
|
slider_loading.value = proc;
|
|
|
|
|
texts[1].text = $"{proc * 100f:N0}%";
|
2024-12-15 01:39:39 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-10 07:25:29 +00:00
|
|
|
public void End_Loading(int index)
|
2024-12-15 01:39:39 +00:00
|
|
|
{
|
2025-03-11 23:47:21 +00:00
|
|
|
if (go.activeInHierarchy)
|
2025-03-10 07:25:29 +00:00
|
|
|
{
|
2025-03-11 23:47:21 +00:00
|
|
|
list_loadingComplete[index] = true;
|
|
|
|
|
bool endloading = true;
|
|
|
|
|
for (int i = 0; i < list_loadingComplete.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
endloading = list_loadingComplete[i];
|
|
|
|
|
if (!endloading) break;
|
|
|
|
|
}
|
2025-03-10 07:25:29 +00:00
|
|
|
|
2025-03-11 23:47:21 +00:00
|
|
|
if (endloading)
|
|
|
|
|
{
|
|
|
|
|
Load_Img();
|
|
|
|
|
go.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-15 01:39:39 +00:00
|
|
|
}
|
|
|
|
|
}
|