public static AssetStoreProductInfo ParseProductInfo(AssetStoreUtils assetStoreUtils, string productId, IDictionary <string, object> productDetail) { if (string.IsNullOrEmpty(productId) || productDetail == null || !productDetail.Any()) { return(null); } return(new AssetStoreProductInfo(assetStoreUtils, productId, productDetail)); }
public void ResolveDependencies(ApplicationProxy application, AssetStoreUtils assetStoreUtils, IOProxy systemIOProxy) { m_Application = application; m_IOProxy = systemIOProxy; foreach (var productInfo in m_ProductInfos.Values) { productInfo.ResolveDependencies(assetStoreUtils); } }
public void ResolveDependencies(UnityConnectProxy unityConnect, UnityOAuthProxy unityOAuth, AssetStoreUtils assetStoreUtils, HttpClientFactory httpClientFactory) { m_UnityConnect = unityConnect; m_UnityOAuth = unityOAuth; m_AssetStoreUtils = assetStoreUtils; m_HttpClientFactory = httpClientFactory; }
public void ResolveDependencies(AssetStoreUtils assetStoreUtils, IOProxy ioProxy) { if (m_Versions == null) { return; } foreach (var version in m_Versions) { version.ResolveDependencies(assetStoreUtils, ioProxy); } }
private AssetStoreProductInfo(AssetStoreUtils assetStoreUtils, string productId, IDictionary <string, object> productDetail) { ResolveDependencies(assetStoreUtils); id = productId; description = CleanUpHtml(productDetail.GetString("description")) ?? string.Empty; var publisher = productDetail.GetDictionary("productPublisher"); if (publisher != null) { if (publisher.GetString("url") == "http://unity3d.com") { author = "Unity Technologies Inc."; } else { author = publisher.GetString("name") ?? L10n.Tr("Unknown publisher"); } publisherId = publisher.GetString("externalRef") ?? string.Empty; } else { author = string.Empty; publisherId = string.Empty; } packageName = productDetail.GetString("packageName") ?? string.Empty; category = productDetail.GetDictionary("category")?.GetString("name") ?? string.Empty; publishNotes = productDetail.GetString("publishNotes") ?? string.Empty; firstPublishedDate = productDetail.GetDictionary("properties")?.GetString("firstPublishedDate"); var versionInfo = productDetail.GetDictionary("version"); if (versionInfo != null) { versionString = versionInfo.GetString("name"); versionId = versionInfo.GetString("id"); publishedDate = versionInfo.GetString("publishedDate"); } displayName = productDetail.GetString("displayName"); supportedVersions = productDetail.GetList <string>("supportedUnityVersions")?.ToList(); state = productDetail.GetString("state"); images = GetImagesFromProductDetails(productDetail); links = GetLinksFromProductDetails(productDetail); sizeInfos = GetSizeInfoFromProductDetails(productDetail); assetStoreLink = GetAssetStoreLinkFromProductDetails(productDetail); }
private void GetAccessToken(Action <AccessToken> doneCallback) { GetAuthCode(authCode => { if (m_AccessToken?.IsValid() ?? false) { doneCallback?.Invoke(m_AccessToken); return; } m_OnAccessTokenFetched += doneCallback; if (m_AccessTokenRequest != null) { return; } var secret = m_UnityConnect.GetConfigurationURL(CloudConfigUrl.CloudPackagesKey); m_AccessTokenRequest = m_HttpClientFactory.PostASyncHTTPClient( $"{host}{k_OAuthUri}", $"grant_type=authorization_code&code={authCode}&client_id=packman&client_secret={secret}&redirect_uri=packman://unity"); m_AccessTokenRequest.header["Content-Type"] = "application/x-www-form-urlencoded"; m_AccessTokenRequest.doneCallback = httpClient => { m_AccessTokenRequest = null; m_AccessToken = null; var response = AssetStoreUtils.ParseResponseAsDictionary(httpClient, OnGetAccessTokenError); if (response != null) { var accessToken = new AccessToken(response); if (accessToken.IsValid()) { m_AccessToken = accessToken; m_OnAccessTokenFetched?.Invoke(m_AccessToken); m_OnAccessTokenFetched = null; return; } else { OnGetAccessTokenError(L10n.Tr("Access token invalid")); } } }; m_AccessTokenRequest.Begin(); }); }
public void ResolveDependencies(UnityConnectProxy unityConnect, AssetStoreCache assetStoreCache, AssetStoreUtils assetStoreUtils, AssetStoreRestAPI assetStoreRestAPI, UpmClient upmClient, IOProxy ioProxy) { m_UnityConnect = unityConnect; m_AssetStoreCache = assetStoreCache; m_AssetStoreUtils = assetStoreUtils; m_AssetStoreRestAPI = assetStoreRestAPI; m_UpmClient = upmClient; m_IOProxy = ioProxy; m_ListOperation?.ResolveDependencies(unityConnect, assetStoreRestAPI); }
private void GetUserInfo(Action <UserInfo> doneCallback) { GetTokenInfo(tokenInfo => { if (m_UserInfo?.isValid ?? false) { doneCallback?.Invoke(m_UserInfo); m_OnError = null; return; } m_OnUserInfoFetched += doneCallback; if (m_UserInfoRequest != null) { return; } m_UserInfoRequest = ApplicationUtil.instance.GetASyncHTTPClient($"{m_Host}{k_UserInfoUri}/{tokenInfo.sub}"); m_UserInfoRequest.header["Authorization"] = "Bearer " + tokenInfo.accessToken; m_UserInfoRequest.doneCallback = httpClient => { m_UserInfoRequest = null; m_UserInfo = null; var response = AssetStoreUtils.ParseResponseAsDictionary(httpClient, OnOperationError); if (response != null) { var userInfo = new UserInfo(response, tokenInfo); if (userInfo.isValid) { m_UserInfo = userInfo; m_OnUserInfoFetched?.Invoke(m_UserInfo); m_OnUserInfoFetched = null; // note that we only clear error callbacks on the when user info is fetched // as we need the error callback to be present for the whole process. m_OnError = null; } else { OnOperationError("UserInfo invalid"); } } }; m_UserInfoRequest.Begin(); }); }
public AssetStorePackage(AssetStoreUtils assetStoreUtils, IOProxy ioProxy, AssetStorePurchaseInfo purchaseInfo, AssetStoreProductInfo productInfo, UpmPackage package) { ResolveDependencies(assetStoreUtils, ioProxy); m_Errors = new List <UIError>(); m_Progress = PackageProgress.None; m_Type = PackageType.AssetStore; m_Name = package?.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_Labels = purchaseInfo?.tags; m_PurchasedTimeTicks = !string.IsNullOrEmpty(purchaseInfo?.purchasedTime) ? DateTime.Parse(purchaseInfo?.purchasedTime).Ticks : 0; m_UpmVersionList = package?.versions as UpmVersionList ?? new UpmVersionList(ioProxy); if (productInfo != null) { foreach (var version in m_UpmVersionList.Cast <UpmPackageVersion>()) { version.UpdateProductInfo(productInfo); } } m_AssetStoreLink = productInfo?.assetStoreLink.url; var firstPublishedDateString = productInfo?.firstPublishedDate ?? string.Empty; m_FirstPublishedDateTicks = !string.IsNullOrEmpty(firstPublishedDateString) ? DateTime.Parse(firstPublishedDateString).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 (string.IsNullOrEmpty(package?.name)) { AddError(new UIError(UIErrorCode.AssetStorePackageError, L10n.Tr("Invalid package info."))); } }
private void GetAccessToken(Action <AccessToken> doneCallback) { GetAuthCode(authCode => { if (m_AccessToken?.IsValid() ?? false) { doneCallback?.Invoke(m_AccessToken); return; } m_OnAccessTokenFetched += doneCallback; if (m_AccessTokenRequest != null) { return; } m_AccessTokenRequest = ApplicationUtil.instance.GetASyncHTTPClient($"{m_Host}{k_OAuthUri}", "POST"); m_AccessTokenRequest.postData = $"grant_type=authorization_code&code={authCode}&client_id=packman&client_secret={m_Secret}&redirect_uri=packman://unity"; m_AccessTokenRequest.header["Content-Type"] = "application/x-www-form-urlencoded"; m_AccessTokenRequest.doneCallback = httpClient => { m_AccessTokenRequest = null; m_AccessToken = null; var response = AssetStoreUtils.ParseResponseAsDictionary(httpClient, OnGetAccessTokenError); if (response != null) { var accessToken = new AccessToken(response); if (accessToken.IsValid()) { m_AccessToken = accessToken; m_OnAccessTokenFetched?.Invoke(m_AccessToken); m_OnAccessTokenFetched = null; return; } else { OnGetAccessTokenError("Access token invalid"); } } }; m_AccessTokenRequest.Begin(); }); }
public void ResolveDependencies(ApplicationProxy application, HttpClientFactory httpClientFactory, UnityConnectProxy unityConnect, AssetStoreCache assetStoreCache, AssetStoreUtils assetStoreUtils, AssetStoreRestAPI assetStoreRestAPI) { m_Application = application; m_UnityConnect = unityConnect; m_HttpClientFactory = httpClientFactory; m_AssetStoreCache = assetStoreCache; m_AssetStoreUtils = assetStoreUtils; m_AssetStoreRestAPI = assetStoreRestAPI; foreach (var operation in m_DownloadOperations.Values) { operation.ResolveDependencies(assetStoreUtils, assetStoreRestAPI); } }
private void GetTokenInfo(Action <TokenInfo> doneCallback) { GetAccessToken(accessToken => { if (m_TokenInfo?.IsValid() ?? false) { doneCallback?.Invoke(m_TokenInfo); return; } m_OnTokenInfoFetched += doneCallback; if (m_TokenRequest != null) { return; } m_TokenRequest = ApplicationUtil.instance.GetASyncHTTPClient($"{m_Host}{k_TokenInfoUri}?access_token={accessToken.accessToken}"); m_TokenRequest.doneCallback = httpClient => { m_TokenRequest = null; m_TokenInfo = null; var response = AssetStoreUtils.ParseResponseAsDictionary(httpClient, OnOperationError); if (response != null) { var tokenInfo = new TokenInfo(response); if (tokenInfo.IsValid()) { m_TokenInfo = tokenInfo; m_OnTokenInfoFetched?.Invoke(m_TokenInfo); m_OnTokenInfoFetched = null; } else { OnOperationError("TokenInfo invalid"); } } }; m_TokenRequest.Begin(); }); }
public AssetStorePackage(AssetStoreUtils assetStoreUtils, IOProxy ioProxy, string productId, UIError error) { ResolveDependencies(assetStoreUtils, ioProxy); m_Errors = new List <UIError> { error }; m_Progress = PackageProgress.None; m_Type = PackageType.AssetStore; m_Name = string.Empty; m_ProductId = productId; m_Images = new List <PackageImage>(); m_Links = new List <PackageLink>(); m_VersionList = new AssetStoreVersionList(assetStoreUtils, ioProxy); m_UpmVersionList = new UpmVersionList(ioProxy); m_Labels = new List <string>(); m_PurchasedTimeTicks = 0; }
public void ResolveDependencies(UnityConnectProxy unityConnect, AssetDatabaseProxy assetDatabase, AssetStoreUtils assetStoreUtils, AssetStoreClient assetStoreClient, AssetStoreDownloadManager assetStoreDownloadManager, UpmClient upmClient, IOProxy ioProxy) { m_UnityConnect = unityConnect; m_AssetDatabase = assetDatabase; m_AssetStoreClient = assetStoreClient; m_AssetStoreDownloadManager = assetStoreDownloadManager; m_UpmClient = upmClient; m_IOProxy = ioProxy; foreach (var package in m_SerializedAssetStorePackages) { package.ResolveDependencies(assetStoreUtils, ioProxy); } }
private void HandleHttpRequest(IAsyncHTTPClient httpRequest, Action <Dictionary <string, object> > doneCallbackAction, Action <UIError> errorCallbackAction) { AssetStoreOAuth.instance.FetchUserInfo( userInfo => { httpRequest.header["Content-Type"] = "application/json"; httpRequest.header["Authorization"] = "Bearer " + userInfo.accessToken; httpRequest.doneCallback = httpClient => { var parsedResult = AssetStoreUtils.ParseResponseAsDictionary(httpRequest, errorMessage => { errorCallbackAction?.Invoke(new UIError(UIErrorCode.AssetStoreRestApiError, errorMessage)); }); if (parsedResult != null) { doneCallbackAction?.Invoke(parsedResult); } }; httpRequest.Begin(); }, errorCallbackAction); }
public ServicesContainer() { // In the constructor we only need to worry about creating a brand new instance. // In the case of assembly reload, a deserialize step will automatically happen after the constructor // to restore all the serializable states/services and we don't need to worry about that m_HttpClientFactory = new HttpClientFactory(); m_UnityOAuthProxy = new UnityOAuthProxy(); m_SelectionProxy = new SelectionProxy(); m_AssetDatabaseProxy = new AssetDatabaseProxy(); m_UnityConnectProxy = new UnityConnectProxy(); m_ApplicationProxy = new ApplicationProxy(); m_IOProxy = new IOProxy(); m_SettingsProxy = new PackageManagerProjectSettingsProxy(); m_ResourceLoader = new ResourceLoader(); m_AssetStoreCache = new AssetStoreCache(); m_AssetStoreClient = new AssetStoreClient(); m_AssetStoreOAuth = new AssetStoreOAuth(); m_AssetStoreUtils = new AssetStoreUtils(); m_AssetStoreRestAPI = new AssetStoreRestAPI(); m_AssetStoreDownloadManager = new AssetStoreDownloadManager(); m_UpmCache = new UpmCache(); m_UpmClient = new UpmClient(); m_PackageFiltering = new PackageFiltering(); m_PackageManagerPrefs = new PackageManagerPrefs(); m_PackageDatabase = new PackageDatabase(); m_PageManager = new PageManager(); // Since dictionaries doesn't survive through serialization, we always re-create the default registration m_RegisteredObjects = new Dictionary <Type, object>(); RegisterDefaultServices(); m_DependenciesResolved = false; }
public AssetStorePackageVersion(AssetStoreUtils assetStoreUtils, IOProxy ioProxy, AssetStoreProductInfo productInfo, AssetStoreLocalInfo localInfo = null) { if (productInfo == null) { throw new ArgumentNullException(nameof(productInfo)); } ResolveDependencies(assetStoreUtils, ioProxy); m_Errors = new List <UIError>(); m_Tag = PackageTag.Downloadable | PackageTag.Importable; m_PackageUniqueId = productInfo.id; m_Description = productInfo.description; m_Author = productInfo.author; m_PublisherId = productInfo.publisherId; m_Category = productInfo.category; m_PublishNotes = localInfo?.publishNotes ?? productInfo.publishNotes ?? string.Empty; m_VersionString = localInfo?.versionString ?? productInfo.versionString ?? string.Empty; m_VersionId = localInfo?.versionId ?? productInfo.versionId ?? string.Empty; SemVersionParser.TryParse(m_VersionString.Trim(), out m_Version); var publishDateString = localInfo?.publishedDate ?? productInfo.publishedDate ?? string.Empty; m_PublishedDateTicks = !string.IsNullOrEmpty(publishDateString) ? DateTime.Parse(publishDateString).Ticks : 0; m_DisplayName = !string.IsNullOrEmpty(productInfo.displayName) ? productInfo.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 (productInfo.supportedVersions?.Any() ?? false) { foreach (var supportedVersion in productInfo.supportedVersions) { SemVersion?version; bool isVersionParsed = SemVersionParser.TryParse(supportedVersion, 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>(productInfo.sizeInfos); m_SizeInfos.Sort((left, right) => left.supportedUnityVersion.CompareTo(right.supportedUnityVersion)); var state = productInfo.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); }
public void ResolveDependencies(AssetStoreUtils assetStoreUtils) { m_AssetStoreUtils = assetStoreUtils; }
public void ResolveDependencies(AssetStoreUtils assetStoreUtils, IOProxy ioProxy) { m_AssetStoreUtils = assetStoreUtils; m_IOProxy = ioProxy; }
public void ResolveDependencies(AssetStoreUtils assetStoreUtils, AssetStoreRestAPI assetStoreRestAPI) { m_AssetStoreUtils = assetStoreUtils; m_AssetStoreRestAPI = assetStoreRestAPI; }
public void ResolveDependencies(AssetStoreUtils assetStoreUtils, IOProxy ioProxy) { m_VersionList?.ResolveDependencies(assetStoreUtils, ioProxy); m_UpmVersionList?.ResolveDependencies(ioProxy); }
public AssetStoreDownloadOperation(AssetStoreUtils assetStoreUtils, AssetStoreRestAPI assetStoreRestAPI, string productId) { ResolveDependencies(assetStoreUtils, assetStoreRestAPI); m_ProductId = productId; }
public AssetStoreVersionList(AssetStoreUtils assetStoreUtils, IOProxy ioProxy) { ResolveDependencies(assetStoreUtils, ioProxy); m_Versions = new List <AssetStorePackageVersion>(); }