//-------------------------------------------------------------------------------------------------------------
        public static AsyncOperation UnloadSceneAsync(int sSceneBuildIndex, UnloadSceneOptions sOptions, string sSceneIntermission = null, STSTransitionData sDatas = null)
        {
            string tSceneName = SceneManager.GetSceneByBuildIndex(sSceneBuildIndex).name;

            RemoveScene(SceneManager.GetActiveScene().name, tSceneName, sSceneIntermission, sDatas);
            return(null);
        }
        /// <summary>
        /// will unload A scene Async
        /// </summary>
        /// <param name="sceneToUnload">the scene to unload</param>
        /// <param name="mode">the unloading options</param>
        public IEnumerator UnloadSceneAsync(SceneIndexes sceneToUnload, UnloadSceneOptions mode = UnloadSceneOptions.None)
        {
            yield return(new WaitForEndOfFrame());

            StartCoroutine(Loading(true));
            _scenesLoading.Add(SceneManager.UnloadSceneAsync((int)sceneToUnload, mode));
            StartProgressCounters();
        }
Example #3
0
    IEnumerator UnloadLevelAsynchronously_C(int _buildIndex, UnloadSceneOptions _mode)
    {
        AsyncOperation asyncLoad = SceneManager.UnloadSceneAsync(_buildIndex, _mode);

        while (!asyncLoad.isDone)
        {
            yield return(null);
        }
    }
Example #4
0
 public static UniTask UnloadSceneAsync(
     string sceneName,
     Action onCompleted                = null,
     UnloadSceneOptions options        = UnloadSceneOptions.None,
     AsyncOperationProgress onProgress = null)
 {
     return(UnloadSceneAsync(
                sceneName, (ao) => onCompleted?.Invoke(),
                options, onProgress));
 }
Example #5
0
        public static UniTask UnloadSceneAsync(
            string sceneName,
            Action <AsyncOperation> onCompleted = null,
            UnloadSceneOptions options          = UnloadSceneOptions.None,
            AsyncOperationProgress onProgress   = null)
        {
            if (!string.IsNullOrEmpty(sceneName) && SceneManagementSingleton.IsSceneLoadedOrInBackground(sceneName))
            {
                AsyncOperation ao = SceneManager.UnloadSceneAsync(sceneName, options);

                if (onCompleted != null)
                {
                    ao.completed += onCompleted;
                }

                return(ao.ConfigureAwait(Progress.Create <float>(x => onProgress?.Invoke(x))));
            }
            else
            {
                onCompleted?.Invoke(null);

                return(UniTask.CompletedTask);
            }
        }