protected override Task OnUnloadAsync(string id, Scene scene, ISceneUnloadParameters parameters, IContext context) { var provider = context.Get <IProvider <string, ISceneInfo> >(); var info = provider.Get <TInfo>(id); return(OnUnloadAsync(id, scene, info, (TUnloadParameters)parameters, context)); }
private static void LogSceneUnload(string id, ISceneInfo info, ISceneUnloadParameters parameters, Scene scene, bool unloadUnused, bool isAsync = false) { Log.Debug("Manager Scene Loader unloading", new { id, info = new { info.LoaderId, info.Address }, parameters = new { parameters.Options }, scene = new { scene.handle, scene.name, scene.path, scene.buildIndex, scene.rootCount, scene.isSubScene }, unloadUnused, isAsync }); }
protected virtual void OnRemoveScene(string id, Scene scene, ISceneUnloadParameters parameters) { if (Description.RegisterApplicationForScenes && ProviderInstance.TryGet(out IProvider <Scene, IApplication> provider)) { provider.Remove(scene); } }
protected override void OnUnload(string id, Scene scene, ISceneUnloadParameters parameters, IContext context) { var provider = context.Get <IProvider <string, ISceneInfo> >(); var info = provider.Get <TInfo>(id); OnUnload(id, scene, info, (TUnloadParameters)parameters, context); }
protected virtual Task OnUnloadAsync(string id, Scene scene, ISceneUnloadParameters parameters) { ISceneLoader loader = this.GetLoaderByScene(id); Task task = loader.UnloadAsync(id, scene, parameters, Context); return(task); }
private static void LogSceneUnloaded(string id, ISceneUnloadParameters parameters, bool isAsync = false) { Log.Debug("Scene unloaded", new { id, parameters = new { parameters.Options }, isAsync }); }
private static void LogSceneUnloaded(string id, ISceneInfo info, ISceneUnloadParameters parameters, bool unloadUnused, bool isAsync = false) { Log.Debug("Manager Scene Loader unloaded", new { id, info = new { info.LoaderId, info.Address }, parameters = new { parameters.Options }, unloadUnused, isAsync }); }
protected override void OnUnload(string id, Scene scene, ISceneInfo info, ISceneUnloadParameters parameters, IContext context) { LogSceneUnload(id, info, parameters, scene, UnloadUnusedAfterUnload); SceneUtility.UnloadScene(scene, parameters.Options); if (RegisterApplication) { OnUnregisterApplication(scene); } if (UnloadUnusedAfterUnload) { Resources.UnloadUnusedAssets(); } LogSceneUnloaded(id, info, parameters, UnloadUnusedAfterUnload); }
private static void LogSceneUnload(string id, Scene scene, ISceneUnloadParameters parameters, bool isAsync = false) { Log.Debug("Scene unloading", new { id, scene = new { scene.handle, scene.name, scene.path, scene.buildIndex, scene.rootCount, scene.isSubScene }, parameters = new { parameters.Options }, isAsync }); }
public Task UnloadAsync(string id, Scene scene, ISceneUnloadParameters parameters, IContext context) { if (string.IsNullOrEmpty(id)) { throw new ArgumentException("Value cannot be null or empty.", nameof(id)); } if (!scene.IsValid()) { throw new ArgumentException("Value should be valid.", nameof(scene)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } return(OnUnloadAsync(id, scene, parameters, context)); }
public async Task UnloadAsync(string id, Scene scene, ISceneUnloadParameters parameters) { if (string.IsNullOrEmpty(id)) { throw new ArgumentException("Value cannot be null or empty.", nameof(id)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } LogSceneUnload(id, scene, parameters, true); Unloading?.Invoke(id, scene, parameters); OnRemoveScene(id, scene, parameters); await OnUnloadAsync(id, scene, parameters); Instances.Remove(scene); Unloaded?.Invoke(id, parameters); LogSceneUnloaded(id, parameters, true); }
protected SceneLoaderBase(ISceneLoadParameters defaultLoadParameters, ISceneUnloadParameters defaultUnloadParameters) { DefaultLoadParameters = defaultLoadParameters ?? throw new ArgumentNullException(nameof(defaultLoadParameters)); DefaultUnloadParameters = defaultUnloadParameters ?? throw new ArgumentNullException(nameof(defaultUnloadParameters)); }
protected virtual void OnUnload(string id, Scene scene, ISceneUnloadParameters parameters) { ISceneLoader loader = this.GetLoaderByScene(id); loader.Unload(id, scene, parameters, Context); }
public static bool TryGetDefaultUnloadParametersByScene(this ISceneModule sceneModule, string id, out ISceneUnloadParameters parameters) { if (TryGetLoaderByScene(sceneModule, id, out ISceneLoader loader)) { parameters = loader.DefaultUnloadParameters; return(true); } parameters = null; return(false); }
public ManagerSceneLoader(ISceneLoadParameters defaultLoadParameters, ISceneUnloadParameters defaultUnloadParameters) : base(defaultLoadParameters, defaultUnloadParameters) { }
protected override async Task OnUnloadAsync(string id, Scene scene, ISceneInfo info, ISceneUnloadParameters parameters, IContext context) { LogSceneUnload(id, info, parameters, scene, UnloadUnusedAfterUnload, true); var provider = ProviderInstance.Get <IProvider <Scene, AsyncOperation> >(); AsyncOperation operation = SceneManager.UnloadSceneAsync(scene, parameters.Options); provider.Add(scene, operation); while (!operation.isDone) { await Task.Yield(); } provider.Remove(scene); if (RegisterApplication) { OnUnregisterApplication(scene); } if (UnloadUnusedAfterUnload) { operation = Resources.UnloadUnusedAssets(); while (!operation.isDone) { await Task.Yield(); } } LogSceneUnloaded(id, info, parameters, UnloadUnusedAfterUnload, true); }
protected abstract Task OnUnloadAsync(string id, Scene scene, ISceneUnloadParameters parameters, IContext context);
public static void Unload(this ISceneModule sceneModule, string id, Scene scene) { ISceneUnloadParameters parameters = GetDefaultUnloadParametersByScene(sceneModule, id); sceneModule.Unload(id, scene, parameters); }
public static Task UnloadAsync(this ISceneModule sceneModule, string id, Scene scene) { ISceneUnloadParameters parameters = GetDefaultUnloadParametersByScene(sceneModule, id); return(sceneModule.UnloadAsync(id, scene, parameters)); }
protected abstract void OnUnload(string id, Scene scene, ISceneUnloadParameters parameters, IContext context);
protected SceneLoader(ISceneLoadParameters defaultLoadParameters, ISceneUnloadParameters defaultUnloadParameters) : base(defaultLoadParameters, defaultUnloadParameters) { }