Beispiel #1
0
        private static void TryFinish(WebCollectionInfo info, List <PkgInfoListModel.Data> localDatas, List <PkgInfoListModel.Data> datas)
        {
            window.multyDrawersInfo.infos.Add(info);

            if (window.multyDrawersInfo.infos.Count == datas.Count)
            {
                localDatas.RemoveAll((_d) => {
                    string _path = Path.Combine(pkgversionjsonPath, _d.pkg_name + ".json");
                    if (File.Exists(_path))
                    {
                        File.Delete(_path);
                    }
                    return(true);
                });


                if (!string.IsNullOrEmpty(window.multyDrawersInfo.userJson.name))
                {
                    for (int j = 0; j < window.multyDrawersInfo.infos.Count; j++)
                    {
                        if (window.multyDrawersInfo.infos[j].author ==
                            window.multyDrawersInfo.userJson.name)
                        {
                            window.multyDrawersInfo.selfInfos.Add(window.multyDrawersInfo.infos[j]);
                        }
                    }
                }
                window.multyDrawersInfo.FreshDrawers();
            }
        }
Beispiel #2
0
        private static void FreshWebCollection()
        {
            window.multyDrawersInfo.selfInfos.Clear();
            window.multyDrawersInfo.infos.Clear();

            HttpPkg.GetPkgInfoList((m) =>
            {
                var datas = m.data;
                List <PkgInfoListModel.Data> localDatas = new List <PkgInfoListModel.Data>();
                if (File.Exists(pkgjsonPath))
                {
                    localDatas = JsonUtility.FromJson <PkgInfoListModel>(File.ReadAllText(pkgjsonPath)).data;
                }
                File.WriteAllText(pkgjsonPath, JsonUtility.ToJson(m, true));

                for (int i = 0; i < datas.Count; i++)
                {
                    var _data = datas[i];
                    var _tmp  = localDatas.Find((d) =>
                    {
                        return(d.pkg_name == _data.pkg_name && d.last_time == _data.last_time && d.last_version == _data.last_version);
                    });
                    localDatas.RemoveAll((d) => {
                        return(d.pkg_name == _data.pkg_name);
                    });

                    if (_tmp != null)
                    {
                        string path            = Path.Combine(pkgversionjsonPath, _data.pkg_name + ".json");
                        WebCollectionInfo info = JsonUtility.FromJson <WebCollectionInfo>(File.ReadAllText(path));
                        TryFinish(info, localDatas, datas);
                    }
                    else
                    {
                        HttpPkg.GetPkgInfos(_data.pkg_name,
                                            (model) =>
                        {
                            WebCollectionInfo info = new WebCollectionInfo()
                            {
                                name   = model.data[0].pkg_name,
                                author = model.data[0].author,
                            };
                            WebCollectionInfo.Version[] versions = new WebCollectionInfo.Version[model.data.Count];
                            for (int j = 0; j < model.data.Count; j++)
                            {
                                versions[j] = new WebCollectionInfo.Version()
                                {
                                    version      = model.data[j].version,
                                    describtion  = model.data[j].describtion,
                                    dependences  = model.data[j].GetDependences().ToArray(),
                                    helpurl      = model.data[j].help_url,
                                    unityVersion = model.data[j].unity_version,
                                    assetPath    = model.data[j].pkg_path,
                                };
                            }
                            info.versions = versions;
                            File.WriteAllText(Path.Combine(pkgversionjsonPath, info.name + ".json"), JsonUtility.ToJson(info, true));
                            TryFinish(info, localDatas, datas);
                        });
                    }
                }
            });
        }