コード例 #1
0
    /// <summary>
    /// 开始更新
    /// </summary>
    public void StartUpdate()
    {
        string           bundleInfoUrl = _CombineRemotePath(BundleInfoFile);
        UGLFBundleLoader loader        = new UGLFBundleLoader(bundleInfoUrl, string.Empty, _Internal_OnBundleInfoCompleted, EN_RequestType.Text);

        internalBundleState = Internal_En_BundleState.DownloadingBundleInfoFile;
        loader.StartDownload();
    }
コード例 #2
0
    /// <summary>
    /// 内部流程,开始下载远程 Bundle
    /// </summary>
    /// <param name="_enumer"></param>
    private void _Internal_DownloadRemoteBundle(Dictionary <string, BundleInfo> .Enumerator _enumer)
    {
        if (_enumer.MoveNext())
        {
            BundleInfo       info   = _enumer.Current.Value;
            UGLFBundleLoader loader = new UGLFBundleLoader(info.bundleUrl, info.bundleHash.ToString(), (UnityWebRequest _request) =>
            {
                currWebRequest = null;
                if (_request.isNetworkError)
                {
                    internalBundleState = Internal_En_BundleState.DownloadRemoteBundleError;
                }
                else
                {
                    AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(_request);
                    bundleName2BundleDict.Add(bundle.name, bundle);
                    string[] assetNames = bundle.GetAllAssetNames();
                    foreach (string assetFullName in assetNames)
                    {
                        if (assetPath2BundleDict.ContainsKey(assetFullName) == false)
                        {
                            assetPath2BundleDict.Add(assetFullName, bundle);
                        }
                    }

                    downloadedBytes += info.bundleSize;
                    // 递归下载 远程 Bundle
                    _Internal_DownloadRemoteBundle(_enumer);
                }
            }, EN_RequestType.AssetBundle);

            internalBundleState = Internal_En_BundleState.DownloadingRemoteBundle;
            loader.StartDownload();
            currWebRequest = loader.request;
        }
        else
        {
            // 开始下载本地缓存好的 Bundle
            _Internal_LoadLocalBundle(cachedBundleDict.GetEnumerator());
        }
    }
コード例 #3
0
    /// <summary>
    /// 内部流程,加载本地缓存的 Bundle
    /// </summary>
    /// <param name="_enumer"></param>
    private void _Internal_LoadLocalBundle(Dictionary <string, BundleInfo> .Enumerator _enumer)
    {
        if (_enumer.MoveNext())
        {
            BundleInfo       info   = _enumer.Current.Value;
            UGLFBundleLoader loader = new UGLFBundleLoader(info.bundleUrl, info.bundleHash.ToString(), (UnityWebRequest _request) =>
            {
                if (_request.isNetworkError)
                {
                    internalBundleState = Internal_En_BundleState.LoadLocalBundleError;
                }
                else
                {
                    AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(_request);
                    bundleName2BundleDict.Add(bundle.name, bundle);
                    string[] assetNames = bundle.GetAllAssetNames();
                    foreach (string assetFullName in assetNames)
                    {
                        if (assetPath2BundleDict.ContainsKey(assetFullName) == false)
                        {
                            assetPath2BundleDict.Add(assetFullName, bundle);
                        }
                    }

                    // 递归下载 远程 Bundle
                    _Internal_LoadLocalBundle(_enumer);
                }
            }, EN_RequestType.AssetBundle);
            internalBundleState = Internal_En_BundleState.LoadingLocalBundle;
            loader.StartDownload();
        }
        else
        {
            // Bundle 更新流程完成
            internalBundleState = Internal_En_BundleState.UpdateSuccessful;
        }
    }