protected IEnumerable <Scene> RemoveOtherScenes(params string[] request) { var scenes_to_unload = GetLoadedScenes(false) .Where(s => !PermanentScenes.Contains(s.name) && !request.Contains(s.name)) .ToArray(); foreach (var scene in scenes_to_unload) { SceneManager.UnloadSceneAsync(scene); Debug.Log($"Unload {scene.name}"); } return(scenes_to_unload); }
protected virtual IEnumerator Start() { Initialize(); // Wait for all scenes to unload while (GetLoadedScenes(false).Any()) { yield return(new WaitForEndOfFrame()); } // Then add permanent scenes AddScenes(PermanentScenes.ToArray()); // Then load scenes as necessary _OnChangeStateRequest(CurrentState); // Initialize the cached current state _RuntimeCachedCurrentState = _CurrentState; // Begin action queue loop for (; ;) { while (_ActionQueue.Count > 0) { var r = _ActionQueue.Dequeue(); for (; ;) { try { if (!r.MoveNext()) { break; } } catch (Exception ex) { Debug.LogError(ex); break; } yield return(r.Current); } } yield return(null); } }