Пример #1
0
        // IBundleService

        public IAddressableLoader LoadAddressable(params string[] args)
        {
            var ldr = new AddressableLoader();

            _loaders.Add(ldr);
            ldr.CompletedEvent += LdrOnCompleted;
            ldr.DisposeEvent   += LdrOnDispose;

            ldr.Load(args);
            return(ldr);
        }
Пример #2
0
        private void LdrOnDispose(AddressableLoader loader)
        {
            loader.DisposeEvent -= LdrOnDispose;
            _loaders.Remove(loader);

            var sounds = loader.Assets.Where(o => o is AudioSettings).Cast <AudioSettings>()
                         .SelectMany(settings => settings.Clips.Values).SelectMany(clips => clips.Keys)
                         .Distinct().ToArray();
            var windows = loader.Assets.Where(o => (o as GameObject)?.GetComponent <Window>())
                          .Cast <GameObject>().Select(o => o.GetComponent <Window>().WindowId).ToArray();

            if (sounds.Length > 0)
            {
                AudioManager.UnregisterClips(sounds);
            }

            foreach (var windowId in windows)
            {
                WindowManager.UnregisterWindow(windowId);
            }

            Resources.UnloadUnusedAssets();
        }