public void UnloadScenes(SceneRepository.Predicate predicate) { List <System.Type> scenesToUnregister = new List <System.Type> (); foreach (KeyValuePair <System.Type, SceneInfo> entry in scenes) { if (entry.Value.controller) { if (entry.Value.controller.ShouldUnload()) { if (predicate(entry.Value.controller)) { GameObject.Destroy(entry.Value.controller.gameObject); UnityEngine.SceneManagement.SceneManager.UnloadScene(entry.Value.name); scenesToUnregister.Add(entry.Key); } } } } //now unregister scenes foreach (System.Type item in scenesToUnregister) { UnRegisterScene(item); } }
public List <SceneController> GetScenes(SceneRepository.Predicate predicate) { List <SceneController> list = new List <SceneController>(); foreach (KeyValuePair <System.Type, SceneInfo> entry in scenes) { if (entry.Value.controller) { if (predicate(entry.Value.controller)) { list.Add(entry.Value.controller); } } } return(list); }