private void GetDataFromPackageLockServer(Dictionary <string, object> data) { providersSet.Clear(); try { object dependencies; if (data.TryGetValue("dependencies", out dependencies)) { if (dependencies != null) { foreach (var item in dependencies as Dictionary <string, object> ) { ProviderModel info = new ProviderModel(); if (ZBasePackageIdConfig.ListPackages.ContainsKey(item.Key)) { if (info.GetFromJson(item.Key, item.Value as Dictionary <string, object>)) { providersSet.Add(info.providerName, info); if (info.currentUnityVersion != "none") { ZLog.Info(string.Format("***Package {0} on server, version {1}***", info.displayProviderName, info.latestUnityVersion)); } } } } } } progressLoadData++; ZBaseEditorCoroutines.StartEditorCoroutine(GetVersionForEmbeddedPack()); } catch (Exception e) { ZLog.Error("Error Get Version From Package Lock Server: " + e.Message); } }
// local private IEnumerator GetVersionFromPackageLockLocal() { while (!IsLoadDataServerDone()) { yield return(new WaitForSeconds(0.1f)); } Dictionary <string, object> dic = new Dictionary <string, object>(); providersLocal.Clear(); try { string fileContent = File.ReadAllText(PackLockLocalDir); dic = Json.Deserialize(fileContent) as Dictionary <string, object>; object dependencies; if (dic.TryGetValue("dependencies", out dependencies)) { if (dependencies != null) { foreach (var item in dependencies as Dictionary <string, object> ) { ProviderModel info = new ProviderModel(); if (ZBasePackageIdConfig.ListPackages.ContainsKey(item.Key)) { if (info.GetFromJson(item.Key, item.Value as Dictionary <string, object>)) { providersLocal.Add(info.providerName, info); if (info.currentUnityVersion != "none") { ZLog.Info(string.Format(">>>Package {0} on local, version {1}<<<", info.displayProviderName, info.currentUnityVersion)); } } } } foreach (var item in providersLocal) { ProviderModel info = item.Value; if (info.source == ZBaseEnum.Source.embedded && info.currentUnityVersion == "none") { LoadPackageFromLocal(info.providerName, info.GetVersionInfoFromLocal); } else if (info.source == ZBaseEnum.Source.git && info.currentUnityVersion == "none" && !string.IsNullOrEmpty(info.hash)) { LoadPackageCacheFromLocal(info.providerName, info.hash, info.GetVersionInfoFromLocal); } } CompareVersion(); //check package not install if (providersLocal.Count != ZBasePackageIdConfig.ListPackages.Count) //skip item package manager { foreach (var item in ZBasePackageIdConfig.ListPackages) { if (providersLocal.ContainsKey(item.Key)) { continue; } if (!providersSet.ContainsKey(item.Key)) { continue; } ProviderModel info = providersSet[item.Key].ShallowCopy(); info.currentStatues = ZBaseEnum.Status.none; info.currentUnityVersion = "none"; if (!item.Key.StartsWith("com")) { info.source = ZBaseEnum.Source.package; } providersLocal.Add(info.providerName, info); ZLog.Info(string.Format(">>>Package {0} not install<<<", info.displayProviderName)); } } } } SortListLocal(); ScopedRegistryConfig(); } catch (Exception e) { ZLog.Info("Error Get Version From Package Lock Local: " + e.Message); } var packageImport = EditorPrefs.GetString("key_package_import", string.Empty); if (!string.IsNullOrEmpty(packageImport)) { if (providersSet.Keys.Contains(packageImport)) { ImportPackage(providersSet[packageImport]); } EditorPrefs.SetString("key_package_import", string.Empty); } Repaint(); }