1. 게임 시작시 로딩화면을 띄워준다

2. 메인으로 사용하는 Scene SceneManager.LoadSceneAsync 불러온다.

    • LoadSceneAsync Scene 로딩을 비동기로 진행해준다.
    • LoadSceneAsync함수의 2번째 인자에 LoadSceneMode.Additive 넣어주면 현재 Scene 바로 닫지 않고 추가로 불러오게 된다.

이렇게 되면 현재 Scene에서는 로딩화면이나 애니메이션이 재생되어 플레이어는 로딩렉 현상을 느끼지 못하게 된다.3. 현재 Scene UnloadSceneAsync 이용하여 비동기로 종료해준다.

 

4. 불러온 메인 Scene Start함수에서 로딩화면을 비활성화 시켜준다.

 

[CurrentScene]

void Start()
{
	if(LoadingImage)
		LoadingImage.SetActive(true);

	StartCoroutine(SceneLoading());
}

IEnumerator SceneLoading()
{
	var mAsyncOperation = SceneManager.LoadSceneAsync("NextSceneName", LoadSceneMode.Additive);

	yield return mAsyncOperation;

	mAsyncOperation = SceneManager.UnloadSceneAsync("CurrentSceneName");

	yield return mAsyncOperation;
}

 

[NextScene]

void Start()
{
	if(LoadingImage)
		LoadingImage.SetActive(false);
}

+ Recent posts