어드레서블 다운로드 % 정상적으로 나오게 수정

This commit is contained in:
Ino 2025-01-02 10:07:33 +09:00
parent 58866cb339
commit b2de1d473e
4 changed files with 17 additions and 15 deletions

View File

@ -34,11 +34,9 @@ public class MainToTitle : MonoBehaviour
IEnumerator Co_CheckDownload() IEnumerator Co_CheckDownload()
{ {
//yield return Addressables.InitializeAsync();
label_slider.text = ""; label_slider.text = "";
long downloadSize = 0; long totalDownloadSize = 0;
int completedDownloads = 0; long currentDownloadedSize = 0; // 현재까지 다운로드된 용량
int totalLabels = addr_Labels.Count; int totalLabels = addr_Labels.Count;
var labels = new List<string>(); var labels = new List<string>();
@ -51,7 +49,7 @@ public class MainToTitle : MonoBehaviour
bool calcSuccess = false; bool calcSuccess = false;
for (int retry = 0; retry < retryLimit; retry++) for (int retry = 0; retry < retryLimit; retry++)
{ {
downloadSize = 0; totalDownloadSize = 0;
calcSuccess = true; calcSuccess = true;
foreach (var label in labels) foreach (var label in labels)
{ {
@ -60,7 +58,7 @@ public class MainToTitle : MonoBehaviour
if (handle.Status == AsyncOperationStatus.Succeeded) if (handle.Status == AsyncOperationStatus.Succeeded)
{ {
downloadSize += handle.Result; totalDownloadSize += handle.Result;
} }
else else
{ {
@ -86,9 +84,9 @@ public class MainToTitle : MonoBehaviour
} }
// 다운로드 크기 출력 // 다운로드 크기 출력
if (downloadSize > 0) if (totalDownloadSize > 0)
{ {
label_popup.text = $"다운로드 안내\n\n최신 패치 파일을 받아야 합니다.\n총 {FormatSize(downloadSize)}를 다운로드 합니다.\n\nWifi로 다운로드 하는 것을 권장합니다."; label_popup.text = $"다운로드 안내\n\n최신 패치 파일을 받아야 합니다.\n총 {FormatSize(totalDownloadSize)}를 다운로드 합니다.\n\nWifi로 다운로드 하는 것을 권장합니다.";
go_popup.SetActive(true); go_popup.SetActive(true);
while (!startDownload) yield return null; // 팝업에서 OK 누를 때까지 대기 while (!startDownload) yield return null; // 팝업에서 OK 누를 때까지 대기
@ -98,7 +96,6 @@ public class MainToTitle : MonoBehaviour
// 다운로드 시작 // 다운로드 시작
foreach (var label in labels) foreach (var label in labels)
{ {
// 다운로드 크기 계산
var handle = Addressables.GetDownloadSizeAsync(label); var handle = Addressables.GetDownloadSizeAsync(label);
yield return handle; yield return handle;
@ -110,15 +107,16 @@ public class MainToTitle : MonoBehaviour
while (!downHandle.IsDone) while (!downHandle.IsDone)
{ {
slider_download.value = (float)(completedDownloads + downHandle.PercentComplete) / totalLabels; float progress = (float)currentDownloadedSize / totalDownloadSize;
label_slider.text = $"{(slider_download.value * 100f).ToString("N2")}%"; slider_download.value = progress;
label_slider.text = $"{progress * 100f:N2}%";
yield return null; yield return null;
} }
if (downHandle.Status == AsyncOperationStatus.Succeeded) if (downHandle.Status == AsyncOperationStatus.Succeeded)
{ {
++completedDownloads; // 다운로드 완료 후 currentDownloadedSize에 추가
slider_download.value = (float)completedDownloads / totalLabels; currentDownloadedSize += handle.Result;
} }
else else
{ {

View File

@ -93,15 +93,15 @@ public class table_missionbase : MonoBehaviour
//json = $"{{\"table_abilityconfig\":{json}}}"; //json = $"{{\"table_abilityconfig\":{json}}}";
} }
} }
#if UNITY_EDITOR
protected void Set_lastjson2() protected void Set_lastjson2()
{ {
#if UNITY_EDITOR
// TODO 정인호 : 임의로 만든 json 파일 오류 처리 (정식에선 지워야함) // TODO 정인호 : 임의로 만든 json 파일 오류 처리 (정식에선 지워야함)
int startIndex = json_last.IndexOf(","); // 첫 번째 객체 시작 int startIndex = json_last.IndexOf(","); // 첫 번째 객체 시작
int endIndex = json_last.IndexOf(",") + 1; // 첫 번째 객체 끝 int endIndex = json_last.IndexOf(",") + 1; // 첫 번째 객체 끝
json_last = json_last.Remove(startIndex, endIndex - startIndex); json_last = json_last.Remove(startIndex, endIndex - startIndex);
}
#endif #endif
}
protected virtual void Start() { LoadComplete = true; } protected virtual void Start() { LoadComplete = true; }
public bool Get_LoadComplete() { return LoadComplete; } public bool Get_LoadComplete() { return LoadComplete; }
} }

View File

@ -0,0 +1,4 @@
{
"EnvironmentName": "production",
"EnvironmentId": "aed3f247-7248-4a9e-a859-b52f7aaae216"
}