Пример #1
0
    public List <string> CalModifyAB(ABHashCollection serverABHashCollection)
    {
        List <string> modifyABList = new List <string>();
        Dictionary <string, ABHashInfo> clientABHashDict = new Dictionary <string, ABHashInfo>();

        for (int i = 0; i < abHashList.Count; i++)
        {
            clientABHashDict.Add(abHashList[i].ab, abHashList[i]);
        }

        ABHashInfo tempS, tempC;

        for (int i = 0; i < serverABHashCollection.abHashList.Count; i++)
        {
            tempC = null;
            tempS = serverABHashCollection.abHashList[i];

            clientABHashDict.TryGetValue(tempS.ab, out tempC);
            if (tempC == null || !tempS.hash.Equals(tempC.hash))
            {
                modifyABList.Add(tempS.ab);
                ABUtil.Log(string.Format("modify ab: {0}", tempS.ab));
            }
        }
        return(modifyABList);
    }
Пример #2
0
    /// <summary>
    /// 生成文件
    /// </summary>
    /// <param name="abManif"></param>
    private static void GenFile(AssetBundleManifest abManif)
    {
        string filePath = ABSettings.AssetBundleCompareFilePath();

        FileStream   fs            = new FileStream(filePath, FileMode.Create);
        StreamWriter mStreamWriter = new StreamWriter(fs, System.Text.Encoding.UTF8);

        ABHashCollection abHashCollection = new ABHashCollection();
        ABHashInfo       abHashInfo       = null;

        string[] abs = abManif.GetAllAssetBundles();
        for (int i = 0; i < abs.Length; i++)
        {
            abHashInfo      = new ABHashInfo();
            abHashInfo.ab   = abs[i];
            abHashInfo.hash = abManif.GetAssetBundleHash(abs[i]).ToString();
            abHashCollection.abHashList.Add(abHashInfo);
        }

        string jsonStr = JsonUtility.ToJson(abHashCollection);

        ABUtil.Log("Gen Json Success: " + jsonStr);
        mStreamWriter.Write(jsonStr);

        mStreamWriter.Close();
        fs.Close();
    }
Пример #3
0
    /// <summary>
    /// 读取Json对比文件
    /// </summary>
    public ABHashCollection ReadABCompareFile()
    {
        ABHashCollection abHashCollection = new ABHashCollection();
        string           filePath         = ClientCompareFilePath();

        if (!File.Exists(filePath))
        {
            return(abHashCollection);
        }

        try
        {
            FileStream   fs           = new FileStream(filePath, FileMode.Open);
            StreamReader streamReader = new StreamReader(fs);

            string jsonStr = streamReader.ReadToEnd();
            abHashCollection = JsonUtility.FromJson <ABHashCollection>(jsonStr);

            streamReader.Close();
            fs.Close();
        }
        catch (Exception e)
        {
            ABUtil.Log(e.Message);
        }
        return(abHashCollection);
    }
Пример #4
0
    private void GenServerJsonCollection(byte[] jsonBytes)
    {
        //网页下载下来的字符串前3个字节是Coding,例子如下
        //http://answers.unity3d.com/questions/844423/wwwtext-not-reading-utf-8-text.html
        string jsonStr = System.Text.Encoding.UTF8.GetString(jsonBytes, 3, jsonBytes.Length - 3);

        mServerHashCollection = JsonUtility.FromJson <ABHashCollection>(jsonStr);
    }
Пример #5
0
    /// <summary>
    /// 读取本地Local文件的比较文件
    /// </summary>
    public static void ReadABCompareFile()
    {
        ABHashCollection abHashCollection = new ABHashCollection();
        string           filePath         = ABSettings.LocalCompareFilePath();

        try
        {
            FileStream   fs           = new FileStream(filePath, FileMode.Open);
            StreamReader streamReader = new StreamReader(fs);

            string jsonStr = streamReader.ReadToEnd();
            ABUtil.Log("read jsonStr: " + jsonStr);
            streamReader.Close();
            fs.Close();
        }
        catch (Exception e)
        {
            ABUtil.Log(e.Message);
        }
    }
Пример #6
0
    private IEnumerator LoadLocalAssetBundle()
    {
        ABHashCollection hashCollection = mABChekcer.ReadABCompareFile();

        yield return(StartCoroutine(mABDownloader.DownloadAndCacheABList(hashCollection.GetNameList())));
    }
Пример #7
0
 private void GenClientJsonCollection()
 {
     mClientHashCollection = ReadABCompareFile();
 }