Пример #1
0
    public static void BuildCollectionsResByInfo(BuildCollectionResInfo info)
    {
        string              fileName = Application.streamingAssetsPath + "/" + info.CollectionID + "ver.txt";
        List <VerInfo>      allList  = new List <VerInfo>();
        List <BuildResInfo> list     = new List <BuildResInfo>(info.builds);

        for (int i = list.Count - 1; i >= 0; i--)
        {
            BuildInfoAB    build = new BuildInfoAB(list[i]);
            List <VerInfo> infos = build.BuildAb(2);
            foreach (VerInfo _v in infos)
            {
                if (_v != null)
                {
                    allList.Add(_v);
                }
            }
        }
        VerInfo buildinfo = new VerInfo();

        foreach (VerInfo ver in allList)
        {
            buildinfo.ver = ver.ver;
            buildinfo.files.AddRange(ver.files);
        }
        string txtStr = JsonUtility.ToJson(buildinfo, true);

        File.WriteAllText(fileName, txtStr);
        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
    }
Пример #2
0
    /// <summary>
    /// 生成某个配置文件的AB
    /// </summary>
    /// <param name="info"></param>
    public static void BuildResByInfo(BuildResInfo info, int flag)
    {
        string  fileName = Application.streamingAssetsPath + "/0ver.txt";
        VerInfo oldVer   = null;

        if (File.Exists(fileName))
        {
            oldVer = JsonUtility.FromJson <VerInfo>(File.ReadAllText(fileName));
        }
        BuildInfoAB    build   = new BuildInfoAB(info);
        List <VerInfo> newInfo = build.BuildAb(flag);

        if (oldVer != null)
        {
            foreach (VerInfo verinfo in newInfo)
            {
                foreach (ABInfo ver in verinfo.files)
                {
                    bool has = false;
                    foreach (ABInfo _ver in oldVer.files)
                    {
                        if (ver.fileName == _ver.fileName)
                        {
                            _ver.length = ver.length;
                            _ver.assets = ver.assets;
                            _ver.sha1   = ver.sha1;
                            has         = true;
                        }
                    }
                    if (!has)
                    {
                        oldVer.files.Add(ver);
                    }
                }
            }
        }
        else
        {
            VerInfo buildinfo = new VerInfo();
            foreach (VerInfo ver in newInfo)
            {
                buildinfo.ver = ver.ver;
                buildinfo.files.AddRange(ver.files);
            }
            oldVer = buildinfo;
        }
        string txtStr = JsonUtility.ToJson(oldVer, true);

        File.WriteAllText(fileName, txtStr);
    }