public async UniTask LoadSceneAsync( int buildIdx, bool setActiveAsMainScene = false, Action <AsyncOperation> onStarted = null, Action onCompleted = null, bool allowSceneActivation = true, AsyncOperationProgress onProgress = null) { if (buildIdx == -1) { return; } if (!_loadedScenes.Contains(buildIdx)) { _loadedScenes.Add(buildIdx); } else { return; } await UniRxAsyncSceneManagementSingleton.LoadSceneAsync( buildIdx, setActiveAsMainScene, onStarted, onCompleted, allowSceneActivation, onProgress); }
public virtual bool LoadSceneAsync( string sceneName, LoadSceneMode mode = LoadSceneMode.Single, Action <AsyncOperation> onComplete = null, bool allowSceneActivation = true, AsyncOperationProgress onProgress = null) { if (!IsSceneLoadedOrInBackground(sceneName)) { if (m_asyncLoadOperation == null) { StartCoroutine(LoadSceneCo(sceneName, mode)); LoadSceneAsync(onComplete, allowSceneActivation, onProgress); m_onAsyncLoadOperationHelper = null; return(true); } else { m_onAsyncLoadOperationHelper += () => { LoadSceneAsync(sceneName, mode, onComplete, allowSceneActivation, onProgress); }; } } else { onComplete?.Invoke(null); } return(false); }
public static UniTask LoadSceneAsync( int buildIndex, bool setActiveAsMainScene = false, Action <AsyncOperation> onStarted = null, Action onCompleted = null, bool allowSceneActivation = true, AsyncOperationProgress onProgress = null, LoadSceneMode mode = LoadSceneMode.Additive) { if (setActiveAsMainScene) { return(LoadSceneAsync(buildIndex, mode, onStarted, () => { if (setActiveAsMainScene) { SceneManagementSingleton.SetActiveScene(buildIndex); } onCompleted?.Invoke(); }, allowSceneActivation, onProgress)); } else { return(LoadSceneAsync(buildIndex, mode, onStarted, () => onCompleted?.Invoke(), allowSceneActivation, onProgress)); } }
public static UniTask LoadSceneAsync( string sceneName, LoadSceneMode mode = LoadSceneMode.Single, Action <AsyncOperation> onStarted = null, Action onCompleted = null, bool allowSceneActivation = true, AsyncOperationProgress onProgress = null) { if (!string.IsNullOrEmpty(sceneName) && !SceneManagementSingleton.IsSceneLoadedOrInBackground(sceneName)) { AsyncOperation ao = SceneManager.LoadSceneAsync(sceneName, mode); ao.allowSceneActivation = allowSceneActivation; onStarted?.Invoke(ao); if (onCompleted != null) { ao.completed += (ctx) => onCompleted.Invoke(); } return(ao.ConfigureAwait(Progress.Create <float>(x => onProgress?.Invoke(x)))); } else { onCompleted?.Invoke(); return(UniTask.CompletedTask); } }
public async UniTask <SceneInstance> LoadSceneAsync( string sceneName, bool activateOnLoad = true, bool setActiveAsMainScene = false, AsyncOperationProgress onProgress = null) { if (string.IsNullOrEmpty(sceneName)) { return(default);
public static UniTask UnloadSceneAsync( string sceneName, Action onCompleted = null, UnloadSceneOptions options = UnloadSceneOptions.None, AsyncOperationProgress onProgress = null) { return(UnloadSceneAsync( sceneName, (ao) => onCompleted?.Invoke(), options, onProgress)); }
protected virtual void LoadSceneAsync( Action <AsyncOperation> onComplete = null, bool allowSceneActivation = true, AsyncOperationProgress onProgress = null) { m_asyncLoadOperation.allowSceneActivation = allowSceneActivation; if (onComplete != null) { m_asyncLoadOperation.completed += onComplete; } if (onProgress != null) { m_onAsyncLoadOperationProgress += onProgress; } m_asyncLoadOperation.completed += OnAsyncLoadOperationCompletedCallback; }
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); } }