예제 #1
0
        /// <summary>
        /// 获取AssetBundle的加载信息
        /// </summary>
        public AssetBundleInfo GetAssetBundleInfo(string bundleName)
        {
            if (_localPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
            {
                // 查询APP资源
                if (_appPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle appPatchBundle))
                {
                    if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
                    {
                        string          appLoadPath = AssetPathHelper.MakeStreamingLoadPath(appPatchBundle.Hash);
                        AssetBundleInfo bundleInfo  = new AssetBundleInfo(bundleName, appLoadPath, appPatchBundle.Version, appPatchBundle.IsEncrypted);
                        return(bundleInfo);
                    }
                }

                // 查询缓存资源
                // 注意:如果沙盒内缓存文件不存在,那么将会从服务器下载
                string sandboxLoadPath = PatchHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
                if (_cache.Contains(patchBundle.Hash))
                {
                    AssetBundleInfo bundleInfo = new AssetBundleInfo(bundleName, sandboxLoadPath, patchBundle.Version, patchBundle.IsEncrypted);
                    return(bundleInfo);
                }
                else
                {
                    string          remoteURL         = GetPatchDownloadURL(patchBundle.Version, patchBundle.Hash);
                    string          remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.Version, patchBundle.Hash);
                    AssetBundleInfo bundleInfo        = new AssetBundleInfo(bundleName, sandboxLoadPath, remoteURL, remoteFallbackURL, patchBundle.Version, patchBundle.IsEncrypted);
                    return(bundleInfo);
                }
            }
            else
            {
                MotionLog.Warning($"Not found bundle in patch manifest : {bundleName}");
                AssetBundleInfo bundleInfo = new AssetBundleInfo(bundleName, string.Empty);
                return(bundleInfo);
            }
        }
예제 #2
0
        /// <summary>
        /// 获取AssetBundle的加载信息
        /// </summary>
        public AssetBundleInfo GetAssetBundleInfo(string bundleName)
        {
            if (_localPatchManifest.Elements.TryGetValue(bundleName, out PatchElement element))
            {
                // 查询内置资源
                if (_appPatchManifest.Elements.TryGetValue(bundleName, out PatchElement appElement))
                {
                    if (appElement.IsDLC() == false && appElement.MD5 == element.MD5)
                    {
                        string          appLoadPath = AssetPathHelper.MakeStreamingLoadPath(appElement.MD5);
                        AssetBundleInfo bundleInfo  = new AssetBundleInfo(bundleName, appLoadPath, string.Empty, appElement.Version, appElement.IsEncrypted);
                        return(bundleInfo);
                    }
                }

                // 查询缓存资源
                // 注意:如果沙盒内缓存文件不存在,那么将会从服务器下载
                string sandboxLoadPath = PatchHelper.MakeSandboxCacheFilePath(element.MD5);
                if (_cache.Contains(element.MD5))
                {
                    AssetBundleInfo bundleInfo = new AssetBundleInfo(bundleName, sandboxLoadPath, string.Empty, element.Version, element.IsEncrypted);
                    return(bundleInfo);
                }
                else
                {
                    string          remoteURL  = GetWebDownloadURL(element.Version.ToString(), element.MD5);
                    AssetBundleInfo bundleInfo = new AssetBundleInfo(bundleName, sandboxLoadPath, remoteURL, element.Version, element.IsEncrypted);
                    return(bundleInfo);
                }
            }
            else
            {
                MotionLog.Warning($"Not found element in patch manifest : {bundleName}");
                AssetBundleInfo bundleInfo = new AssetBundleInfo(bundleName, string.Empty);
                return(bundleInfo);
            }
        }