public AssetStorePackage(AssetStoreFetchedInfo fetchedInfo, AssetStoreLocalInfo localInfo = null) { m_Errors = new List <Error>(); m_Progress = PackageProgress.None; m_Type = PackageType.AssetStore; m_Name = string.Empty; m_ProductId = fetchedInfo?.id.ToString(); m_Images = fetchedInfo?.images ?? new List <PackageImage>(); m_Links = fetchedInfo?.links ?? new List <PackageLink>(); m_VersionList = new AssetStoreVersionList(); m_UpmVersionList = new UpmVersionList(); if (string.IsNullOrEmpty(fetchedInfo?.id) || string.IsNullOrEmpty(fetchedInfo?.versionId)) { AddError(new Error(NativeErrorCode.Unknown, "Invalid product details.")); } else if (localInfo == null) { m_VersionList.AddVersion(new AssetStorePackageVersion(fetchedInfo)); } else { m_VersionList.AddVersion(new AssetStorePackageVersion(fetchedInfo, localInfo)); if (localInfo.canUpdate && (localInfo.versionId != fetchedInfo.versionId || localInfo.versionString != fetchedInfo.versionString)) { m_VersionList.AddVersion(new AssetStorePackageVersion(fetchedInfo)); } } }
private void OnLocalInfoRemoved(AssetStoreLocalInfo localInfo) { var fetchedInfo = m_FetchedInfos.Get(localInfo.id); if (fetchedInfo == null) { return; } var package = new AssetStorePackage(fetchedInfo, (AssetStoreLocalInfo)null); onPackagesChanged?.Invoke(new[] { package }); }
private void OnLocalInfoRemoved(AssetStoreLocalInfo localInfo) { var purchaseInfo = m_PurchaseInfos.Get(localInfo.id); var productInfo = m_ProductInfos.Get(localInfo.id); if (productInfo == null) { return; } var package = new AssetStorePackage(purchaseInfo, productInfo, (AssetStoreLocalInfo)null); onPackagesChanged?.Invoke(new[] { package }); }
private void RefreshLocalInfos() { var infos = AssetStoreUtils.instance.GetLocalPackageList(); var oldLocalInfos = m_LocalInfos; m_LocalInfos = new Dictionary <string, AssetStoreLocalInfo>(); foreach (var info in infos) { var parsedInfo = AssetStoreLocalInfo.ParseLocalInfo(info); var id = parsedInfo?.id; if (string.IsNullOrEmpty(id)) { continue; } var oldInfo = oldLocalInfos.Get(id); if (oldInfo != null) { oldLocalInfos.Remove(oldInfo.id); if (oldInfo.versionId == parsedInfo.versionId && oldInfo.versionString == parsedInfo.versionString && oldInfo.packagePath == parsedInfo.packagePath) { m_LocalInfos[id] = oldInfo; continue; } } m_LocalInfos[id] = parsedInfo; OnLocalInfoChanged(parsedInfo); } foreach (var info in oldLocalInfos.Values) { OnLocalInfoRemoved(info); } }
private void RefreshLocalInfos() { var infos = m_AssetStoreUtils.GetLocalPackageList(); m_AssetStoreCache.SetLocalInfos(infos.Select(info => AssetStoreLocalInfo.ParseLocalInfo(info))); }
public AssetStorePackage(AssetStorePurchaseInfo purchaseInfo, AssetStoreProductInfo productInfo, AssetStoreLocalInfo localInfo = null) { m_Errors = new List <UIError>(); m_Progress = PackageProgress.None; m_Type = PackageType.AssetStore; m_Name = string.Empty; m_ProductId = productInfo?.id.ToString(); m_Images = productInfo?.images ?? new List <PackageImage>(); m_Links = productInfo?.links ?? new List <PackageLink>(); m_VersionList = new AssetStoreVersionList(); m_UpmVersionList = new UpmVersionList(); m_AssetStoreLink = productInfo?.assetStoreLink.url; var firstPublishedDateString = productInfo?.firstPublishedDate ?? string.Empty; m_FirstPublishedDateTicks = !string.IsNullOrEmpty(firstPublishedDateString) ? DateTime.Parse(firstPublishedDateString).Ticks : 0; m_Labels = purchaseInfo?.tags; m_PurchasedTimeTicks = !string.IsNullOrEmpty(purchaseInfo?.purchasedTime) ? DateTime.Parse(purchaseInfo?.purchasedTime).Ticks : 0; if (purchaseInfo == null) { AddError(new UIError(UIErrorCode.AssetStorePackageError, "Invalid purchase details.")); } if (string.IsNullOrEmpty(productInfo?.id) || string.IsNullOrEmpty(productInfo?.versionId)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, ApplicationUtil.instance.GetTranslationForText("Invalid product details."))); } else if (localInfo == null) { m_VersionList.AddVersion(new AssetStorePackageVersion(productInfo)); } else { m_VersionList.AddVersion(new AssetStorePackageVersion(productInfo, localInfo)); if (localInfo.canUpdate && (localInfo.versionId != productInfo.versionId || localInfo.versionString != productInfo.versionString)) { m_VersionList.AddVersion(new AssetStorePackageVersion(productInfo)); } } }
public AssetStorePackage(AssetStoreUtils assetStoreUtils, IOProxy ioProxy, AssetStorePurchaseInfo purchaseInfo, AssetStoreProductInfo productInfo, AssetStoreLocalInfo localInfo = null) { ResolveDependencies(assetStoreUtils, ioProxy); m_Errors = new List <UIError>(); m_Progress = PackageProgress.None; m_Type = PackageType.AssetStore; m_Name = string.Empty; m_ProductId = productInfo?.id.ToString(); m_Images = productInfo?.images ?? new List <PackageImage>(); m_Links = productInfo?.links ?? new List <PackageLink>(); m_VersionList = new AssetStoreVersionList(assetStoreUtils, ioProxy); m_UpmVersionList = new UpmVersionList(ioProxy); m_AssetStoreLink = productInfo?.assetStoreLink.url; var firstPublishedDateString = productInfo?.firstPublishedDate ?? string.Empty; m_FirstPublishedDateTicks = !string.IsNullOrEmpty(firstPublishedDateString) ? DateTime.Parse(firstPublishedDateString).Ticks : 0; m_Labels = purchaseInfo?.tags; m_PurchasedTimeTicks = !string.IsNullOrEmpty(purchaseInfo?.purchasedTime) ? DateTime.Parse(purchaseInfo?.purchasedTime).Ticks : 0; if (purchaseInfo == null) { var errorMessage = L10n.Tr("Unable to get purchase details because you may not have purchased this package."); AddError(new UIError(UIErrorCode.AssetStorePackageError, errorMessage)); } if (string.IsNullOrEmpty(productInfo?.id) || string.IsNullOrEmpty(productInfo?.versionId)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, L10n.Tr("Invalid product details."))); } else if (localInfo == null) { m_VersionList.AddVersion(new AssetStorePackageVersion(assetStoreUtils, ioProxy, productInfo)); } else { m_VersionList.AddVersion(new AssetStorePackageVersion(assetStoreUtils, ioProxy, productInfo, localInfo)); if (localInfo.canUpdate && (localInfo.versionId != productInfo.versionId || localInfo.versionString != productInfo.versionString)) { m_VersionList.AddVersion(new AssetStorePackageVersion(assetStoreUtils, ioProxy, productInfo)); } } }
public AssetStorePackageVersion(AssetStoreFetchedInfo fetchedInfo, AssetStoreLocalInfo localInfo = null) { if (fetchedInfo == null) { throw new ArgumentNullException(nameof(fetchedInfo)); } m_Errors = new List <Error>(); m_Tag = PackageTag.Downloadable | PackageTag.Importable; m_PackageUniqueId = fetchedInfo.id; m_Description = fetchedInfo.description; m_Author = fetchedInfo.author; m_PublisherId = fetchedInfo.publisherId; m_Category = fetchedInfo.category; m_VersionString = localInfo?.versionString ?? fetchedInfo.versionString ?? string.Empty; m_VersionId = localInfo?.versionId ?? fetchedInfo.versionId ?? string.Empty; SemVersionParser.TryParse(m_VersionString.Trim(), out m_Version); var publishDateString = localInfo?.publishedDate ?? fetchedInfo.publishedDate ?? string.Empty; m_PublishedDateTicks = !string.IsNullOrEmpty(publishDateString) ? DateTime.Parse(publishDateString).Ticks : 0; m_DisplayName = !string.IsNullOrEmpty(fetchedInfo.displayName) ? fetchedInfo.displayName : $"Package {m_PackageUniqueId}@{m_VersionId}"; m_SupportedUnityVersions = new List <SemVersion>(); if (localInfo != null) { var simpleVersion = Regex.Replace(localInfo.supportedVersion, @"(?<major>\d+)\.(?<minor>\d+).(?<patch>\d+)[abfp].+", "${major}.${minor}.${patch}"); SemVersionParser.TryParse(simpleVersion.Trim(), out m_SupportedUnityVersion); m_SupportedUnityVersionString = m_SupportedUnityVersion?.ToString(); } else if (fetchedInfo.supportedVersions?.Any() ?? false) { foreach (var supportedVersion in fetchedInfo.supportedVersions) { SemVersion?version; bool isVersionParsed = SemVersionParser.TryParse(supportedVersion as string, out version); if (isVersionParsed) { m_SupportedUnityVersions.Add((SemVersion)version); } } m_SupportedUnityVersions.Sort((left, right) => (left).CompareTo(right)); m_SupportedUnityVersion = m_SupportedUnityVersions.LastOrDefault(); m_SupportedUnityVersionString = m_SupportedUnityVersion?.ToString(); } m_SizeInfos = new List <PackageSizeInfo>(fetchedInfo.sizeInfos); m_SizeInfos.Sort((left, right) => left.supportedUnityVersion.CompareTo(right.supportedUnityVersion)); var state = fetchedInfo.state ?? string.Empty; if (state.Equals("published", StringComparison.InvariantCultureIgnoreCase)) { m_Tag |= PackageTag.Published; } else if (state.Equals("deprecated", StringComparison.InvariantCultureIgnoreCase)) { m_Tag |= PackageTag.Deprecated; } SetLocalPath(localInfo?.packagePath); }