using Fort23.UTool;
using UnityEngine;
using UnityEngine.Networking;

namespace Core.AssetLoadTool.Asset
{
    public class H5BundleLoadTask : BundleLoadBasic
    {
        protected override void StartLoad()
        {
            LoadBudnel();
        }

        private void LoadBudnel()
        {
            string url = AssetBundleLoadManager.Instance.h5Url + bundleName;
            UnityWebRequest webRequest=  UnityWebRequestAssetBundle.GetAssetBundle(url);
            UnityWebRequestAsyncOperation webRequestAsyncOperation= webRequest.SendWebRequest();
            webRequestAsyncOperation.completed+= delegate(AsyncOperation asyncOperation)
            {
                if (webRequest.responseCode == 200)
                {
                    DownloadHandlerAssetBundle downloadHandler= webRequest.downloadHandler as DownloadHandlerAssetBundle;
                    if (downloadHandler.assetBundle == null)
                    {
                        LogTool.Error(" budnle空的" + url + "__" + bundleName);
                    }
                    LoadFinish(downloadHandler.assetBundle);
                }
                else
                {
                    LogTool.Error(url+"_____"+webRequest.error);
                }
            };
           
        }
    }
}