Example #1
0
    public void GoLoad()
    {
        string assetPath = PathHelp.GetDownLoadPath() + PathHelp.unZip + CombinSuffixName(mAssetName);

        Debug.Log("加载assetbundle---" + assetPath);
        mAssetBundle = AssetBundle.LoadFromFile(assetPath);
        if (mAssetBundle != null)
        {
            isLoaded = true;
            if (mAssetBundle.isStreamedSceneAssetBundle)
            {
                mAsset = mAssetBundle.mainAsset;
            }
            else
            {
                mAsset = mAssetBundle.LoadAsset(mAssetName);
                mAssetBundle.Unload(false);
                mAssetBundle = null;
            }
        }
        else
        {
            Debug.Log("未发现assetbundle---" + assetPath);
        }
    }
Example #2
0
    private void SaveVesionToLocal(HTTPResponse response)
    {
        string savePath = PathHelp.GetDownLoadPath();

        if (!Directory.Exists(savePath))
        {
            Directory.CreateDirectory(savePath);
        }
        version_Path = Path.Combine(savePath, version);
        Debug.Log("版本号获得成功--" + response.DataAsText);
        bool isUpdate = VersionController.ReadLocalVersion(response.DataAsText, version_Path);

        if (isUpdate)//需要更新
        {
            RequestVersionList();
        }
        else
        {
            Debug.Log("已是最新版本不需更新");
            if (finish != null)
            {
                finish();
            }
        }
    }
Example #3
0
 // Use this for initialization
 void Awake()
 {
     tempPath = Path.Combine(PathHelp.GetDownLoadPath(), "TempRes.temp");
     if (File.Exists(tempPath))
     {
         File.Delete(tempPath);
     }
     httpImpl = new BestHttpImpl();
     httpImpl.SetHttpParams();
     httpImpl.AddHead("content-type", "application/json");
     PlayerPrefs.SetInt("DownloadProgress", 0);
 }
    //获得Mainfest
    private void GetMainfest()
    {
        string mainPath = PathHelp.GetDownLoadPath() + PathHelp.unZip + mMainfestName;

        Debug.Log("加载mainfest---" + mainPath);
        mMainfestBundle = AssetBundle.LoadFromFile(mainPath);
        if (mMainfestBundle != null)
        {
            mainfest = mMainfestBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
            mMainfestBundle.Unload(false);
            mMainfestBundle = null;
        }
    }
Example #5
0
 /// <summary>
 /// 保存下载的数据到本地
 /// </summary>
 /// <param name="response"></param>
 private void SaveZipToLocal(HTTPResponse response)
 {
     ProcessFragments(response.GetStreamedFragments());
     if (response.IsStreamingFinished)
     {
         Debug.Log("zip资源获得成功");
         string newPath = PathHelp.GetDownLoadPath() + "data.zip";
         if (File.Exists(tempPath))
         {
             if (File.Exists(newPath))
             {
                 File.Delete(newPath);
             }
             File.Move(tempPath, newPath);
             File.Delete(tempPath);
         }
         Zip.UnZip(newPath, PathHelp.GetDownLoadPath() + PathHelp.unZip);
         Debug.Log("解压完成");
         RequestZipNext();
     }
 }
Example #6
0
    public IEnumerator GoLoadAsync()
    {
        string assetPath = PathHelp.GetDownLoadPath() + PathHelp.unZip + CombinSuffixName(mAssetName);

        Debug.Log("异步加载assetbundle---" + assetPath);
        AssetBundleCreateRequest abrequest = AssetBundle.LoadFromFileAsync(assetPath);

        yield return(abrequest);

        if (abrequest.isDone)
        {
            mAssetBundle = abrequest.assetBundle;
            abrequest    = null;
            if (mAssetBundle != null)
            {
                isLoaded = true;
                if (mAssetBundle.isStreamedSceneAssetBundle)
                {
                    mAsset = mAssetBundle.mainAsset;
                }
                else
                {
                    AssetBundleRequest _abr = mAssetBundle.LoadAssetAsync(mAssetName);
                    yield return(_abr);

                    mAsset = _abr.asset;
                    _abr   = null;
                    mAssetBundle.Unload(false);
                    mAssetBundle = null;
                }
            }
            else
            {
                Debug.Log("未发现assetbundle---" + assetPath);
            }
        }
    }