public static void UnloadScene(string key, Action <string> onSucceeded = null, Action <string> onFailed = null, bool autoReleaseHandle = true) { if (!GuardKey(key, out key)) { onFailed?.Invoke(key); return; } if (!_scenes.TryGetValue(key, out var scene)) { onFailed?.Invoke(key); return; } _scenes.Remove(key); try { var operation = Addressables.UnloadSceneAsync(scene, autoReleaseHandle); operation.Completed += handle => OnUnloadSceneCompleted(handle, key, onSucceeded, onFailed); } catch (Exception ex) { if (ExceptionHandle == ExceptionHandleType.Throw) { throw ex; } if (ExceptionHandle == ExceptionHandleType.Log) { Debug.LogException(ex); } } }
public static void UnloadScene(string key, bool autoReleaseHandle = true) { if (!GuardKey(key, out key)) { return; } if (!_scenes.TryGetValue(key, out var scene)) { return; } _scenes.Remove(key); Addressables.UnloadSceneAsync(scene, autoReleaseHandle); }
public static void UnloadScene(string key, bool autoReleaseHandle = true) { if (!GuardKey(key, out key)) { if (ExceptionHandle == ExceptionHandleType.Throw) { throw new InvalidKeyException(key); } if (ExceptionHandle == ExceptionHandleType.Log) { Debug.LogException(new InvalidKeyException(key)); } return; } if (!_scenes.TryGetValue(key, out var scene)) { if (!SuppressWarningLogs) { Debug.LogWarning(Exceptions.NoSceneKeyLoaded(key)); } return; } _scenes.Remove(key); try { Addressables.UnloadSceneAsync(scene, autoReleaseHandle); } catch (Exception ex) { if (ExceptionHandle == ExceptionHandleType.Throw) { throw ex; } if (ExceptionHandle == ExceptionHandleType.Log) { Debug.LogException(ex); } } }
public static void UnloadScene(string key, Action <string> onSucceeded = null, Action <string> onFailed = null, bool autoReleaseHandle = true) { if (!GuardKey(key, out key)) { onFailed?.Invoke(key); return; } if (!_scenes.TryGetValue(key, out var scene)) { onFailed?.Invoke(key); return; } _scenes.Remove(key); var operation = Addressables.UnloadSceneAsync(scene, autoReleaseHandle); operation.Completed += handle => OnUnloadSceneCompleted(handle, key, onSucceeded, onFailed); }
public static IEnumerator UnloadSceneCoroutine(string key, bool autoReleaseHandle = true, Action <string> onSucceeded = null, Action <string> onFailed = null) { if (!GuardKey(key, out key)) { onFailed?.Invoke(key); } else { if (!_scenes.TryGetValue(key, out var scene)) { onFailed?.Invoke(key); } else { _scenes.Remove(key); var operation = Addressables.UnloadSceneAsync(scene, autoReleaseHandle); yield return(operation); OnUnloadSceneCompleted(operation, key, onSucceeded, onFailed); } } }
/// <summary> /// Unloads the reference as a scene. /// </summary> /// <returns>The operation handle for the scene load.</returns> public virtual AsyncOperationHandle <SceneInstance> UnLoadScene() { return(Addressables.UnloadSceneAsync(m_Operation, true)); }