Ejemplo n.º 1
0
        /// <summary>
        /// 强制卸载顶级依赖bundle,必须等待所有正在加载的任务完成
        /// </summary>
        /// <param name="bundleName"></param>
        /// <returns></returns>
        public IEnumerator UnloadBundle(string bundleName)
        {
            while (m_bundleLoading.Count > 0)
            {
                yield return(false);
            }

            while (m_assetLoading.Count > 0)
            {
                yield return(false);
            }

            KTBundleInfo info = null;

            if (m_bundleLoaded.TryGetValue(bundleName, out info))
            {
                if (info.cacheType != BundleCacheType.Share)
                {
                    Debug.LogError("CacheType to Unload Bundle is not BundleCacheType.Share");
                    yield return(false);
                }

                info.Release(true);
                m_bundleLoaded.Remove(bundleName);
            }
            yield return(true);
        }
Ejemplo n.º 2
0
        private void BundleCompleteCallback(KTBundleLoader loader)
        {
            var bundleInfo = new KTBundleInfo()
            {
                name         = loader.requestBundleName,
                bundle       = loader.request.assetBundle,
                cacheType    = loader.cacheType,
                cacheTimeout = loader.cacheTimeout,
                startTime    = 0
            };

            m_bundleLoaded.Add(loader.requestBundleName, bundleInfo);
            loader.Release();
            m_bundleLoading.Remove(loader.requestBundleName);
        }