AddCache() static private method

添加缓存
static private AddCache ( CacheData cacheData ) : void
cacheData CacheData
return void
Exemplo n.º 1
0
        /// <summary>
        /// Adds the source cache data from WW.
        /// </summary>
        /// <param name="www">Www.</param>
        /// <param name="req">Req.</param>
        internal static bool AddSourceCacheDataFromWWW(WWW www, CRequest req)
        {
            object data = null;
            var    ab   = www.assetBundle;

            req.isAssetBundle = false;

            if (ab != null)
            {
                data = ab;
                req.isAssetBundle = true;
                CacheData cacheData = new CacheData(data, null, req.key);                 //缓存
                CacheManager.AddCache(cacheData);
                cacheData.allDependencies = req.allDependencies;
                cacheData.assetBundle     = ab;
            }
            else if (Typeof_String.Equals(req.assetType))
            {
                req.data = www.text;
            }
            else if (Typeof_AudioClip.Equals(req.assetType))
            {
                req.data = www.audioClip;
            }
            else if (Typeof_Texture2D.Equals(req.assetType))
            {
                if (req.assetName.Equals("textureNonReadable"))
                {
                    req.data = www.textureNonReadable;
                }
                else
                {
                    req.data = www.texture;
                }
            }

            if (Typeof_Bytes.Equals(req.assetType))
            {
                req.data          = www.bytes;
                req.isAssetBundle = false;
            }

            req.uris.OnWWWComplete(req, www.bytes);

            www.Dispose();
            return(req.isAssetBundle);
        }
Exemplo n.º 2
0
 internal static bool AddSourceCacheDataFromWWW(AssetBundle ab, CRequest req)
 {
     if (ab)
     {
         req.isAssetBundle = true;
         CacheData cacheData = new CacheData(ab, null, req.key); //缓存
         CacheManager.AddCache(cacheData);
         cacheData.allDependencies = req.allDependencies;
         cacheData.assetBundle     = ab;
         return(req.isAssetBundle);
     }
     else
     {
         req.isAssetBundle = false;
         return(false);
     }
 }