Unity/Unity 이슈

Exception: Reentering the Update method is not allowed. This can happen when calling WaitForCompletion on an operation while inside of a callback.

lipnus 2022. 2. 19. 21:27
반응형

Problem

GameObject loading = 
            Addressables.InstantiateAsync("Assets/Addressable/UI/Loading/LoadingPrefab.prefab", parent).WaitForCompletion();

Exception: Reentering the Update method is not allowed.  This can happen when calling WaitForCompletion on an operation while inside of a callback.

 

 

 

Solution

검색해서 나오는 글들을 보면, Addressable자체 버그인듯 함.

그래서 어찌 해결할 방안이 없음.

 

Coroutine(IEnumerator)안에서 WaitforComplete를 쓰면 저 지랄이 나는듯.

메인쓰레드로 옮겨서 실행해서 일단 이슈는 해결함.

 

	private Queue<UnityAction> actionBuffer = new Queue<UnityAction>();

    private void Update()
    {
        if(actionBuffer.Count > 0) {
            actionBuffer.Dequeue().Invoke();
        }
    }
    
    // ...
    
    private void LoadLoginScene()
    {
        actionBuffer.Enqueue(StartLoadLoadingPrefab);    
    }

    private void StartLoadLoadingPrefab()
    {
        Addressables.InstantiateAsync("Assets/Addressable/UI/Loading/LoadingPrefab.prefab", parent).WaitForCompletion();
    }

'

 

 

반응형