Ejemplo n.º 1
0
    /// <summary>
    /// 读取serverab版本表文件
    /// </summary>
    public void LoadServerABVerDataFile()
    {
        //CReadCsvBase.ReaderCsvData(GameDefine.CsvAssetbundleName, GameDefine.AssetbundleCsvFileName, out strList);

        string path = GameDefine.AppPersistentDataPath + GameDefine.ServerAssetbundleVersionDataFile;

        //检测文件是否存在
        if (!File.Exists(path))
        {
            HttpDownloadMgr.DownFile(GameDefine.LuancherURL, GameDefine.AppPersistentDataPath, GameDefine.ServerAssetbundleVersionDataFile);
        }

        List <string[]> strList;

        CReadCsvBase.ReaderCsvDataFromFile(path, out strList);

        int columnCount = strList.Count;

        for (int i = 2; i < columnCount; i++)
        {
            CServerABVerData tempData = new CServerABVerData();
            uint.TryParse(strList[i][0], out tempData.AssetBundleId);
            tempData.AssetBundleName = strList[i][1];
            //tempData.DownloadUrlPath = strList[i][2];
            uint.TryParse(strList[i][2], out tempData.AssetbundleVersion);
            tempData.AssetbundleMd5Str = strList[i][3];
            tempData.DescriptionStr    = strList[i][4];

            ABDataDictionary.Add(tempData.AssetBundleName, tempData);
        }
    }
Ejemplo n.º 2
0
    public static bool CompareABVersionAndUpdate(string abname, bool bAsyncDown = false, byte gameid = 255)
    {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
        if (!Luancher.UpdateWithLuncher)
        {
            return(false);
        }
#endif
        LocalABVersion   lcABVerdata        = CCsvDataManager.Instance.LocalABVerDataMgr.GetLocalABVersion(abname);
        CServerABVerData sevABVerdata       = CCsvDataManager.Instance.SerABVerDataMgr.GetServerABVerData(abname);
        bool             needDownloadPpdate = false;
        if (sevABVerdata == null)
        {
            Debug.Log("服务器资源表上无此资源,请检查:" + abname);
            return(false);
        }
        if (lcABVerdata == null)
        {
            needDownloadPpdate = true;
        }
        else
        {
            if (lcABVerdata.version == sevABVerdata.AssetbundleVersion)
            {
                needDownloadPpdate = false;
            }
            else
            {
                needDownloadPpdate = true;
                //本地存在可能是旧的版本文件或者是上次未下载完成的的损坏文件先删除
                if (File.Exists(GameDefine.AssetBundleSavePath + abname))
                {
                    File.Delete(GameDefine.AssetBundleSavePath + abname);
                }
            }
        }

        //如果本地没有此资源则更新
        if (!File.Exists(GameDefine.AssetBundleSavePath + abname))
        {
            needDownloadPpdate = true;
        }

        if (needDownloadPpdate)
        {
            if (bAsyncDown)
            {
                HttpDownloadMgr.Instance.RequestDownload(GameDefine.LuancherURL, GameDefine.AssetBundleSavePath, abname, sevABVerdata.AssetbundleVersion, gameid);
            }
            else
            {
                HttpDownloadMgr.DownFile(GameDefine.LuancherURL, GameDefine.AssetBundleSavePath, abname);
                CCsvDataManager.Instance.LocalABVerDataMgr.SetLocalABVersion(abname, sevABVerdata.AssetbundleVersion);
            }
        }
        return(needDownloadPpdate);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 下载更新的assetbundle
    /// </summary>
    private void DownHotfixAndSerABCsvFile()
    {
        if (!Directory.Exists(GameDefine.AssetBundleSavePath))
        {
            Directory.CreateDirectory(GameDefine.AssetBundleSavePath);
        }

        //有更新的话,热更新脚本文件与服务器资源版本文件是必需更新的
        HttpDownloadMgr.DownFile(GameDefine.LuancherURL, GameDefine.AppPersistentDataPath, GameDefine.HotFixLuaFile);
        HttpDownloadMgr.DownFile(GameDefine.LuancherURL, GameDefine.AppPersistentDataPath, GameDefine.ServerAssetbundleVersionDataFile);



        //HttpDownload.DownFile(GameDefine.LuancherURL, GameDefine.AssetBundleSavePath, "hall");

        //         AssetBundleManager.LoadAssetBundleFromLocal(GameDefine.AssetBundleSavePath, "resverab");
        //         AssetBundle bundle = AssetBundleManager.GetAssetBundle("resverab");
        //
        //         TextAsset datatxt = bundle.LoadAsset("AssetbundleConfig.txt", typeof(TextAsset)) as TextAsset;
        //         Debug.Log(datatxt.text);
    }