Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 4
0
        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
     });
 }
Ejemplo n.º 7
0
 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
     });
 }
Ejemplo n.º 8
0
        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
     });
 }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 12
0
 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);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
 public ManagerSceneLoader(ISceneLoadParameters defaultLoadParameters, ISceneUnloadParameters defaultUnloadParameters) : base(defaultLoadParameters, defaultUnloadParameters)
 {
 }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
 protected abstract Task OnUnloadAsync(string id, Scene scene, ISceneUnloadParameters parameters, IContext context);
Ejemplo n.º 18
0
        public static void Unload(this ISceneModule sceneModule, string id, Scene scene)
        {
            ISceneUnloadParameters parameters = GetDefaultUnloadParametersByScene(sceneModule, id);

            sceneModule.Unload(id, scene, parameters);
        }
Ejemplo n.º 19
0
        public static Task UnloadAsync(this ISceneModule sceneModule, string id, Scene scene)
        {
            ISceneUnloadParameters parameters = GetDefaultUnloadParametersByScene(sceneModule, id);

            return(sceneModule.UnloadAsync(id, scene, parameters));
        }
Ejemplo n.º 20
0
 protected abstract void OnUnload(string id, Scene scene, ISceneUnloadParameters parameters, IContext context);
 protected SceneLoader(ISceneLoadParameters defaultLoadParameters, ISceneUnloadParameters defaultUnloadParameters) : base(defaultLoadParameters, defaultUnloadParameters)
 {
 }