public static async Task AsTask(this AsyncOperation asyncOperation) { if (asyncOperation == null) { return; } AsyncOperationWrapper wrapper = new AsyncOperationWrapper(asyncOperation); await wrapper.Task; }
public void NextScene(int nextLevel) { Log.Assert(_asyncOp == null, "Scene transition already in progress!"); Log.Debug("SceneTransition", "Set next level {0}", nextLevel); #if USE_UNITY_PRO asyncOp = Application.LoadLevelAsync(nextLevel); // TODO: Scene name or index! #else _asyncOp = new AsyncOperationWrapper(nextLevel); #endif _asyncOp.allowSceneActivation = false; // Should wait for the fade. audioPlayer.FadeOut(1f/4f); Animator a = this.gameObject.GetComponent<Animator>(); a.Play("FadeOut"); }