using System;
using UnityEngine;
using UnityEngine.UI;

public class GlobalUIManager : BaseUIManager
{
    public static GlobalUIManager Instance;

    [SerializeField] private Loading _sceneLoading;

    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this; //만들어진 자신을 인스턴스로 설정
        }
        else
        {
            Destroy(gameObject); //이미 인스턴스가 있으면 자신을 파괴
        }
    }

    private void Start()
    {
        SetSceneLoadingActive(false);
    }

    public void SetSceneLoadingActive(bool flag)
    {
        _sceneLoading.gameObject.SetActive(flag);
    }

    public void SetSceneLoadingProgressValue(float value)
    {
        _sceneLoading.LoadingImage.fillAmount = value;
        _sceneLoading.LoadingTextMeshProUGUI.text = $"{(value * 100):F0}% 로딩 중...";
    }
    public void SetSceneLoadingProgressValue(float value,string loadingText)
    {
        _sceneLoading.LoadingImage.fillAmount = value;
        _sceneLoading.LoadingTextMeshProUGUI.text = loadingText;
    }
}
