TIL

25.04.15 TIL

gaon99 2025. 4. 15. 21:58

1. 오늘 학습 키워드

 

어드레서블


2. 오늘 학습 한 내용을 나만의 언어로 정리하기

 

어드레서블 로드에 대해서 공부를 하고 이것을 적용하는 걸 오늘 목표로 삼았다.

 

우선 TIPSO를 text에 연결하는것까지는 해결했는데, 로드까지는 못했다.

오늘 찍먹이 목표였는데,

어.. 찍기까지 밖에 못했다.

 

그 외에 텍스트가 랜덤으로 뜨도록 코루틴을 제작했고

 

일단 디버그가 뜨지는 않지만 굴러가진 않지만. 찍먹했다도르로 코드를 남겨놓으려고한다..

public class LoadingController : ControllerUI
{
    [SerializeField] private LoadingUI loadingUI;
    [SerializeField] private string labelToLoad = "Card";
    [SerializeField] private float tipChangeInterval = 2f;
    [SerializeField] private List<TipSO> tips;
    
    private AddressableManager addrManager;

    protected override void Start()
    {
        base.Start(); // InitAllUIs() 호출됨
        addrManager = new AddressableManager();
        LoadAssetsWithUI();
        StartCoroutine(ChangeTipsLoop());
    }

    private IEnumerator ChangeTipsLoop()
    {
        while (true)
        {
            if (tips.Count > 0)
            {
                var randomTip = tips[Random.Range(0, tips.Count)];
                loadingUI.SetText(randomTip);
            }

            yield return new WaitForSeconds(tipChangeInterval);
        }
    }


    private async void LoadAssetsWithUI()
    {var labelExists = await Addressables.LoadResourceLocationsAsync(labelToLoad).Task;
        if (labelExists.Count == 0)
        {
            Debug.LogError($"라벨 '{labelToLoad}'에 해당하는 에셋이 없습니다!");
            return;
        }
        List<CardSO> loadedAssets = await addrManager.LoadGroupAssetsAsync<CardSO>(
            labelToLoad,
            onComplete: () => Debug.Log("Loading done!") // Action 대리자로 변경
        );
    }

    private void OnDestroy()
    {
        addrManager.UnloadAssets(labelToLoad);
    }
}

 

그리고 이건 Loading 씬 작업을 시작하면서 UI를 점점 추가할 예정이다.

public class LoadingUI : BaseUI
{
    [SerializeField] private Image progressBar;
    [SerializeField] private TextMeshProUGUI tipText;
    
    public override void Initialize()
    {
        Hide();
        SetProgress(0);
    }

    public void SetText(TipSO text)
    {
        tipText.text = text.Desc;
    }
    
    public void SetProgress(float progress)
    {
        progressBar.fillAmount = Mathf.Clamp01(progress);
    }

3. 학습하며 겪었던 문제점 & 에러

 

어드레서블 로드가 안됩니다 이거 사람이 눈이 돌아갈지도 모르겠어요


4. 내일 학습 할 것은 무엇인지

 

어드레서블 로드 꼭 해낸다..

 

'TIL' 카테고리의 다른 글

25.04.17 TIL  (0) 2025.04.17
25.04.16 TIL  (0) 2025.04.16
25.04.14 TIL  (0) 2025.04.14
25.04.11 TIL  (0) 2025.04.11
25.04.10 TIL  (0) 2025.04.10