Exemplo n.º 1
0
        /// <summary>
        /// 检查是否已经从网络下载
        /// </summary>
        protected WWW IsLoadAssetBundleAtInternal(string assetBundleName)
        {
            //已经存在了呀
            LOAssetBundle bundle = LOAssetCache.GetBundleCache(assetBundleName);

            if (bundle != null)
            {
                //保留一次
                bundle.Retain();
                return(null);
            }

            //如果WWW缓存策略中包含有对应的关键字,则返回null
            if (LOAssetCache.InWWWCache(assetBundleName))
            {
                return(null);
            }
            //创建下载链接
            WWW www = new WWW(LOAssetManager.URI + assetBundleName);

            //加入缓存策略
            LOAssetCache.SetWWWCache(assetBundleName, www);

            return(www);
        }
Exemplo n.º 2
0
 public void Release()
 {
     this.m_ReferencedCount--;
     //当引用计数为0时,卸载资源
     if (this.m_ReferencedCount == 0)
     {
         this.m_AssetBundle.Unload(true);
         LOAssetCache.FreeBundle(this.m_AssetBundleName);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>The asset.</returns>
        public T GetAsset <T>(string assetbundlename, string assetname) where T : UnityEngine.Object
        {
            LOAssetBundle lab = LOAssetCache.GetBundleCache(assetbundlename);

            if (lab == null)
            {
                return(null);
            }
            else
            {
                return(lab.m_AssetBundle.LoadAsset <T>(assetname));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 加载资源包
        /// </summary>
        IEnumerator LoadAssetBundle(string assetBundleName)
        {
            if (LOAssetCache.InCache(assetBundleName))
            {
                yield break;
            }
            // 通过网络下载AssetBundle
            WWW www = IsLoadAssetBundleAtInternal(assetBundleName);

            yield return(www);

            // 通过网络加载失败,下载依赖包裹
            yield return(StartCoroutine(LoadDependencies(assetBundleName)));
        }
Exemplo n.º 5
0
        IEnumerator LoadManifestBundle()
        {
            if (LOAssetCache.InCache(LOAssetManager.ManifestName))
            {
                yield break;
            }

            // 通过网络下载AssetBundle
            WWW www = IsLoadAssetBundleAtInternal(LOAssetManager.ManifestName);

            yield return(www);

            this.manifest = this.GetAsset <AssetBundleManifest>(LOAssetManager.ManifestName, "AssetBundleManifest");
            LOAssetManager.InitBlock(this.manifest != null);
        }
Exemplo n.º 6
0
        IEnumerator LoadDependencies(string assetBundleName)
        {
            if (this.manifest == null)
            {
                yield break;
            }
            // 获取依赖包裹
            string[] dependencies = this.manifest.GetAllDependencies(assetBundleName);

            if (dependencies.Length == 0)
            {
                yield break;
            }

            // 记录并且加载所有的依赖包裹
            LOAssetCache.SetDependCache(assetBundleName, dependencies);

            for (int i = 0; i < dependencies.Length; i++)
            {
                yield return(IsLoadAssetBundleAtInternal(dependencies[i]));
            }
        }
Exemplo n.º 7
0
 void Update()
 {
     LOAssetCache.Update();
 }