コード例 #1
0
        private void OnProductPackageChanged(string productId, IPackage package)
        {
            var purchaseInfo = m_AssetStoreCache.GetPurchaseInfo(productId);
            var productInfo  = m_AssetStoreCache.GetProductInfo(productId);

            if (productInfo != null)
            {
                var assetStorePackage = new AssetStorePackage(m_AssetStoreUtils, m_IOProxy, purchaseInfo, productInfo, package as UpmPackage);
                onPackagesChanged?.Invoke(new[] { assetStorePackage });
            }
        }
コード例 #2
0
        private void OnProductPackageFetchError(string productId, UIError error)
        {
            var purchaseInfo = m_AssetStoreCache.GetPurchaseInfo(productId);
            var productInfo  = m_AssetStoreCache.GetProductInfo(productId);

            if (productInfo != null)
            {
                var assetStorePackage        = new AssetStorePackage(m_AssetStoreUtils, m_IOProxy, purchaseInfo, productInfo);
                var assetStorePackageVersion = assetStorePackage.versions.primary as AssetStorePackageVersion;
                assetStorePackageVersion.SetUpmPackageFetchError(error);
                onPackagesChanged?.Invoke(new[] { assetStorePackage });
            }
        }
コード例 #3
0
        public virtual void FetchDetail(long productId, Action <IPackage> doneCallbackAction = null)
        {
            m_AssetStoreRestAPI.GetProductDetail(productId, productDetail =>
            {
                IPackage package = null;
                var error        = productDetail.GetString("errorMessage");
                var idString     = productId.ToString();
                if (string.IsNullOrEmpty(error))
                {
                    var productInfo = AssetStoreProductInfo.ParseProductInfo(m_AssetStoreUtils, idString, productDetail);
                    if (productInfo == null)
                    {
                        package = new AssetStorePackage(m_AssetStoreUtils, m_IOProxy, idString, new UIError(UIErrorCode.AssetStoreClientError, L10n.Tr("Error parsing product details.")));
                    }
                    else
                    {
                        var oldProductInfo = m_AssetStoreCache.GetProductInfo(idString);
                        if (oldProductInfo == null || oldProductInfo.versionId != productInfo.versionId || oldProductInfo.versionString != productInfo.versionString)
                        {
                            if (string.IsNullOrEmpty(productInfo.packageName))
                            {
                                package = new AssetStorePackage(m_AssetStoreUtils, m_IOProxy, m_AssetStoreCache.GetPurchaseInfo(idString), productInfo, m_AssetStoreCache.GetLocalInfo(idString));
                            }
                            else
                            {
                                m_UpmClient.FetchForProduct(idString, productInfo.packageName);
                            }
                            m_AssetStoreCache.SetProductInfo(productInfo);
                        }
                    }
                }
                else
                {
                    var purchaseInfo = m_AssetStoreCache.GetPurchaseInfo(idString);
                    m_AssetStoreCache.RemoveProductInfo(idString);
                    var uiError = new UIError(UIErrorCode.AssetStoreClientError, error);
                    package     = new PlaceholderPackage(idString, purchaseInfo?.displayName ?? string.Empty, PackageType.AssetStore, PackageTag.Downloadable, PackageProgress.None, uiError);
                }

                if (package != null)
                {
                    onPackagesChanged?.Invoke(new[] { package });
                }

                doneCallbackAction?.Invoke(package);
            });
        }