IEnumerator WaitForLoadLevel(int level, bool additive = false) { loadingScreen.Show(); OnLoadBegin.Dispatch(); #if (UNITY_5_2 || UNITY_5_1 || UNITY_5_0) AsyncOperation oper = additive ? Application.LoadLevelAdditiveAsync(level) : Application.LoadLevelAsync(level); #else AsyncOperation oper = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(level, additive ? LoadSceneMode.Additive : LoadSceneMode.Single); #endif OnProgress.Dispatch(oper.progress); while (!oper.isDone) { yield return(new WaitForFixedUpdate()); OnProgress.Dispatch(oper.progress); loadingScreen.OnProgress(oper.progress); } Resources.UnloadUnusedAssets(); OnLoadEnd.Dispatch(); loadingScreen.Hide(); }