Exemple #1
0
 private void OnBundleWebRequestSaveComplete(BundleWebSaveRequest request)
 {
     if (m_CacheManager != null)
     {
         m_CacheManager.UpdateCacheItem(request.bundleFullname, request.hash);
     }
 }
Exemple #2
0
        public static BundleWebSaveRequest CreateBundleWebSaveRequest(string url, string localPath, string hash = null, string fullName = null)
        {
            BundleWebSaveRequest request = BundleWebSaveRequestPool.Get();

            request.bundleUrl      = url;
            request.hash           = hash;
            request.saveFilePath   = localPath;
            request.bundleFullname = fullName;
            request.timeout        = AMSetting.DownloadTimeout;
            request.retryTimes     = AMSetting.RequestRetryTimes;
            return(request);
        }
Exemple #3
0
        public virtual Request CreateAssetBundleRequest(AssetBundleInfo assetBundleInfo)
        {
            if (assetBundleInfo == null)
            {
                return(null);
            }

            if (m_CacheManager != null)
            {
                //use cache
                if (m_CacheManager.IsCached(assetBundleInfo.fullName, assetBundleInfo.hash))
                {
                    //load from cache
                    string assetPath = AssetPaths.GetFullPath(assetBundleInfo.fullName);
                    return(CreateBundleCreateRequest(assetPath));
                }
                else
                {
                    //download and save to cache
                    string url      = AssetPaths.GetUrl(assetBundleInfo.fullName);
                    string savePath = AssetPaths.ToBundlePath(assetBundleInfo.fullName);
                    BundleWebSaveRequest webSaveRequest = CreateBundleWebSaveRequest(url, savePath, assetBundleInfo.hash, assetBundleInfo.fullName);
                    webSaveRequest.onSaveComplete += OnBundleWebRequestSaveComplete;
                    return(webSaveRequest);
                }
            }
            else
            {
                //no cache
                string assetPath = AssetPaths.GetFullPath(assetBundleInfo.fullName);
#if ASSETMANAGER_LOG_ON
                Debug.LogFormat("[AssetManage]LoadBundle {0}---{1}", assetPath, Time.frameCount);
#endif
                if (assetPath.Contains("://"))
                {
                    return(CreateBundleWebRequest(assetPath));
                }
                else
                {
                    return(CreateBundleCreateRequest(assetPath));
                }
            }
        }
Exemple #4
0
 public static void ReleaseBundleWebSaveRequest(BundleWebSaveRequest request)
 {
     BundleWebSaveRequestPool.Release(request);
 }