public static void Login(string loginReason, AssetStoreLoginWindow.LoginCallback callback) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type AssetStoreLoginWindow.\u003CLogin\u003Ec__AnonStorey59 loginCAnonStorey59 = new AssetStoreLoginWindow.\u003CLogin\u003Ec__AnonStorey59(); // ISSUE: reference to a compiler-generated field loginCAnonStorey59.callback = callback; // ISSUE: reference to a compiler-generated field loginCAnonStorey59.loginReason = loginReason; if (AssetStoreClient.HasActiveSessionID) { AssetStoreClient.Logout(); } if (!AssetStoreClient.RememberSession || !AssetStoreClient.HasSavedSessionID) { // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field AssetStoreLoginWindow.ShowAssetStoreLoginWindow(loginCAnonStorey59.loginReason, loginCAnonStorey59.callback); } else { // ISSUE: reference to a compiler-generated method AssetStoreClient.LoginWithRememberedSession(new AssetStoreClient.DoneLoginCallback(loginCAnonStorey59.\u003C\u003Em__99)); } }
/** Make a best effort login to the asset store by trying on order: * 1, reuse previously saved session * 2, show login window */ static public void Login(string loginReason, LoginCallback callback) { if (AssetStoreClient.HasActiveSessionID) { AssetStoreClient.Logout(); } // Show login window if we cannot use saved session ID if (!AssetStoreClient.RememberSession || !AssetStoreClient.HasSavedSessionID) { ShowAssetStoreLoginWindow(loginReason, callback); return; } AssetStoreClient.LoginWithRememberedSession(delegate(string errorMessage) { if (string.IsNullOrEmpty(errorMessage)) { callback(errorMessage); } else { ShowAssetStoreLoginWindow(loginReason, callback); } }); }
private static AssetStoreResponse ParseContent(AsyncHTTPClient job) { AssetStoreResponse assetStoreResponse = new AssetStoreResponse(); assetStoreResponse.job = job; assetStoreResponse.dict = (Dictionary <string, JSONValue>)null; assetStoreResponse.ok = false; AsyncHTTPClient.State state = job.state; string text = job.text; if (!AsyncHTTPClient.IsSuccess(state)) { Console.WriteLine(text); return(assetStoreResponse); } string status; string message; assetStoreResponse.dict = AssetStoreClient.ParseJSON(text, out status, out message); if (status == "error") { Debug.LogError((object)("Request error (" + status + "): " + message)); return(assetStoreResponse); } assetStoreResponse.ok = true; return(assetStoreResponse); }
internal static AsyncHTTPClient SearchAssets(string searchString, string[] requiredClassNames, string[] assetLabels, List <AssetStoreClient.SearchCount> counts, AssetStoreResultBase <AssetStoreSearchResults> .Callback callback) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type AssetStoreClient.\u003CSearchAssets\u003Ec__AnonStorey54 assetsCAnonStorey54 = new AssetStoreClient.\u003CSearchAssets\u003Ec__AnonStorey54(); string str1 = string.Empty; string str2 = string.Empty; string str3 = string.Empty; string str4 = string.Empty; using (List <AssetStoreClient.SearchCount> .Enumerator enumerator = counts.GetEnumerator()) { while (enumerator.MoveNext()) { AssetStoreClient.SearchCount current = enumerator.Current; str1 = str1 + str4 + (object)current.offset; str2 = str2 + str4 + (object)current.limit; str3 = str3 + str4 + current.name; str4 = ","; } } if (Array.Exists <string>(requiredClassNames, (Predicate <string>)(a => a.Equals("MonoScript", StringComparison.OrdinalIgnoreCase)))) { Array.Resize <string>(ref requiredClassNames, requiredClassNames.Length + 1); requiredClassNames[requiredClassNames.Length - 1] = "Script"; } string url = string.Format("{0}&q={1}&c={2}&l={3}&O={4}&N={5}&G={6}", (object)AssetStoreClient.APISearchUrl("/search/assets"), (object)Uri.EscapeDataString(searchString), (object)Uri.EscapeDataString(string.Join(",", requiredClassNames)), (object)Uri.EscapeDataString(string.Join(",", assetLabels)), (object)str1, (object)str2, (object)str3); // ISSUE: reference to a compiler-generated field assetsCAnonStorey54.r = new AssetStoreSearchResults(callback); // ISSUE: reference to a compiler-generated method return(AssetStoreClient.CreateJSONRequest(url, new AssetStoreClient.DoneCallback(assetsCAnonStorey54.\u003C\u003Em__92))); }
public static void Login(string loginReason, AssetStoreLoginWindow.LoginCallback callback) { if (AssetStoreClient.HasActiveSessionID) { AssetStoreClient.Logout(); } if (!AssetStoreClient.RememberSession || !AssetStoreClient.HasSavedSessionID) { AssetStoreLoginWindow.ShowAssetStoreLoginWindow(loginReason, callback); } else { AssetStoreClient.LoginWithRememberedSession(delegate(string errorMessage) { if (string.IsNullOrEmpty(errorMessage)) { callback(errorMessage); } else { AssetStoreLoginWindow.ShowAssetStoreLoginWindow(loginReason, callback); } }); } }
private static AssetStoreResponse ParseContent(AsyncHTTPClient job) { AssetStoreResponse assetStoreResponse = new AssetStoreResponse(); assetStoreResponse.job = job; assetStoreResponse.dict = null; assetStoreResponse.ok = false; AsyncHTTPClient.State state = job.state; string text = job.text; if (!AsyncHTTPClient.IsSuccess(state)) { Console.WriteLine(text); return(assetStoreResponse); } string text2; string str; assetStoreResponse.dict = AssetStoreClient.ParseJSON(text, out text2, out str); if (text2 == "error") { Debug.LogError("Request error (" + text2 + "): " + str); return(assetStoreResponse); } assetStoreResponse.ok = true; return(assetStoreResponse); }
// Refresh information about displayed asset by quering the // asset store server. This is typically after the user has // logged in because we need to know if he already owns the // displayed asset. public static void RefreshFromServer(AssetsRefreshed callback) { if (s_SelectedAssets.Count == 0) { return; } // Refetch assetInfo // Query the asset store for more info List <AssetStoreAsset> queryAssets = new List <AssetStoreAsset>(); foreach (KeyValuePair <int, AssetStoreAsset> qasset in s_SelectedAssets) { queryAssets.Add(qasset.Value); } // This will fill the queryAssets with extra preview data AssetStoreClient.AssetsInfo(queryAssets, delegate(AssetStoreAssetsInfo results) { AssetStoreAssetInspector.paymentAvailability = AssetStoreAssetInspector.PaymentAvailability.ServiceDisabled; if (!string.IsNullOrEmpty(results.error)) { System.Console.WriteLine("Error performing Asset Store Info search: " + results.error); AssetStoreAssetInspector.OfflineNoticeEnabled = true; //Debug.LogError("Error performing Asset Store Info search: " + results.error); if (callback != null) { callback(); } return; } AssetStoreAssetInspector.OfflineNoticeEnabled = false; if (results.status == AssetStoreAssetsInfo.Status.Ok) { AssetStoreAssetInspector.paymentAvailability = AssetStoreAssetInspector.PaymentAvailability.Ok; } else if (results.status == AssetStoreAssetsInfo.Status.BasketNotEmpty) { AssetStoreAssetInspector.paymentAvailability = AssetStoreAssetInspector.PaymentAvailability.BasketNotEmpty; } else if (results.status == AssetStoreAssetsInfo.Status.AnonymousUser) { AssetStoreAssetInspector.paymentAvailability = AssetStoreAssetInspector.PaymentAvailability.AnonymousUser; } AssetStoreAssetInspector.s_PurchaseMessage = results.message; AssetStoreAssetInspector.s_PaymentMethodCard = results.paymentMethodCard; AssetStoreAssetInspector.s_PaymentMethodExpire = results.paymentMethodExpire; AssetStoreAssetInspector.s_PriceText = results.priceText; AssetStoreAssetInspector.Instance.Repaint(); if (callback != null) { callback(); } }); }
private static AsyncHTTPClient CreateJSONRequestDelete(string url, AssetStoreClient.DoneCallback callback) { AsyncHTTPClient asyncHttpClient = new AsyncHTTPClient(url, "DELETE"); asyncHttpClient.header["X-Unity-Session"] = AssetStoreClient.ActiveOrUnauthSessionID + AssetStoreClient.GetToken(); asyncHttpClient.doneCallback = AssetStoreClient.WrapJsonCallback(callback); asyncHttpClient.Begin(); return(asyncHttpClient); }
internal static AsyncHTTPClient BuildPackage(AssetStoreAsset asset, AssetStoreResultBase <BuildPackageResult> .Callback callback) { string url = AssetStoreClient.APIUrl("/content/download/" + asset.packageID.ToString()); BuildPackageResult r = new BuildPackageResult(asset, callback); return(AssetStoreClient.CreateJSONRequest(url, delegate(AssetStoreResponse ar) { r.Parse(ar); })); }
private static AsyncHTTPClient CreateJSONRequestPost(string url, Dictionary <string, string> param, AssetStoreClient.DoneCallback callback) { AsyncHTTPClient asyncHttpClient = new AsyncHTTPClient(url); asyncHttpClient.header["X-Unity-Session"] = AssetStoreClient.ActiveOrUnauthSessionID + AssetStoreClient.GetToken(); asyncHttpClient.postDictionary = param; asyncHttpClient.doneCallback = AssetStoreClient.WrapJsonCallback(callback); asyncHttpClient.Begin(); return(asyncHttpClient); }
public static void RefreshFromServer(AssetStoreAssetSelection.AssetsRefreshed callback) { if (AssetStoreAssetSelection.s_SelectedAssets.Count == 0) { return; } List <AssetStoreAsset> list = new List <AssetStoreAsset>(); foreach (KeyValuePair <int, AssetStoreAsset> current in AssetStoreAssetSelection.s_SelectedAssets) { list.Add(current.Value); } AssetStoreClient.AssetsInfo(list, delegate(AssetStoreAssetsInfo results) { AssetStoreAssetInspector.paymentAvailability = AssetStoreAssetInspector.PaymentAvailability.ServiceDisabled; if (results.error != null && results.error != string.Empty) { Console.WriteLine("Error performing Asset Store Info search: " + results.error); AssetStoreAssetInspector.OfflineNoticeEnabled = true; if (callback != null) { callback(); } return; } AssetStoreAssetInspector.OfflineNoticeEnabled = false; if (results.status == AssetStoreAssetsInfo.Status.Ok) { AssetStoreAssetInspector.paymentAvailability = AssetStoreAssetInspector.PaymentAvailability.Ok; } else { if (results.status == AssetStoreAssetsInfo.Status.BasketNotEmpty) { AssetStoreAssetInspector.paymentAvailability = AssetStoreAssetInspector.PaymentAvailability.BasketNotEmpty; } else { if (results.status == AssetStoreAssetsInfo.Status.AnonymousUser) { AssetStoreAssetInspector.paymentAvailability = AssetStoreAssetInspector.PaymentAvailability.AnonymousUser; } } } AssetStoreAssetInspector.s_PurchaseMessage = results.message; AssetStoreAssetInspector.s_PaymentMethodCard = results.paymentMethodCard; AssetStoreAssetInspector.s_PaymentMethodExpire = results.paymentMethodExpire; AssetStoreAssetInspector.s_PriceText = results.priceText; AssetStoreAssetInspector.Instance.Repaint(); if (callback != null) { callback(); } }); }
void BuildPackage() { AssetStoreAsset.PreviewInfo item = m_Asset.previewInfo; if (item == null) { return; } if (m_BuildAttempts++ > kMaxPolls) { EditorUtility.DisplayDialog("Building timed out", "Timed out during building of package", "Close"); Close(); return; } item.downloadProgress = -1f; m_Purchasing = PurchaseStatus.Building; AssetStoreClient.BuildPackage(m_Asset, delegate(BuildPackageResult result) { if (this == null) { return; // aborted } if (result.error != null) { Debug.Log(result.error); if (EditorUtility.DisplayDialog("Error building package", "The server was unable to build the package. Please re-import.", "Ok")) { Close(); } return; } if (m_Asset == null || m_Purchasing != PurchaseStatus.Building || result.packageID != m_Asset.packageID) { // Aborted Close(); } string url = result.asset.previewInfo.packageUrl; if (url != null && url != "") { DownloadPackage(); } else { // Retry since package is not done building on server m_Purchasing = PurchaseStatus.StartBuild; } Repaint(); }); }
private void InitiateBuySelected(bool firstAttempt) { AssetStoreAsset firstAsset = AssetStoreAssetSelection.GetFirstAsset(); if (firstAsset == null) { EditorUtility.DisplayDialog("No asset selected", "Please select asset before buying a package", "ok"); } else if (AssetStoreAssetInspector.paymentAvailability == AssetStoreAssetInspector.PaymentAvailability.AnonymousUser) { if (AssetStoreClient.LoggedIn()) { AssetStoreAssetSelection.RefreshFromServer(delegate { this.InitiateBuySelected(false); }); } else if (firstAttempt) { this.LoginAndInitiateBuySelected(); } } else if (AssetStoreAssetInspector.paymentAvailability == AssetStoreAssetInspector.PaymentAvailability.ServiceDisabled) { if (firstAsset.previewInfo == null) { return; } AssetStore.Open(string.Format("content/{0}/directpurchase", firstAsset.packageID)); } else if (AssetStoreAssetInspector.paymentAvailability == AssetStoreAssetInspector.PaymentAvailability.BasketNotEmpty) { if (firstAsset.previewInfo == null) { return; } if (firstAttempt) { AssetStoreAssetSelection.RefreshFromServer(delegate { this.InitiateBuySelected(false); }); } else { AssetStore.Open(string.Format("content/{0}/basketpurchase", firstAsset.packageID)); } } else { AssetStoreInstaBuyWindow.ShowAssetStoreInstaBuyWindow(firstAsset, AssetStoreAssetInspector.s_PurchaseMessage, AssetStoreAssetInspector.s_PaymentMethodCard, AssetStoreAssetInspector.s_PaymentMethodExpire, AssetStoreAssetInspector.s_PriceText); } }
internal static AsyncHTTPClient BuildPackage(AssetStoreAsset asset, AssetStoreResultBase <BuildPackageResult> .Callback callback) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type AssetStoreClient.\u003CBuildPackage\u003Ec__AnonStorey57 packageCAnonStorey57 = new AssetStoreClient.\u003CBuildPackage\u003Ec__AnonStorey57(); string url = AssetStoreClient.APIUrl("/content/download/" + asset.packageID.ToString()); // ISSUE: reference to a compiler-generated field packageCAnonStorey57.r = new BuildPackageResult(asset, callback); // ISSUE: reference to a compiler-generated method return(AssetStoreClient.CreateJSONRequest(url, new AssetStoreClient.DoneCallback(packageCAnonStorey57.\u003C\u003Em__95))); }
internal static AsyncHTTPClient DirectPurchase(int packageID, string password, AssetStoreResultBase <PurchaseResult> .Callback callback) { string url = AssetStoreClient.APIUrl(string.Format("/purchase/direct/{0}", packageID.ToString())); PurchaseResult r = new PurchaseResult(callback); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary["password"] = password; return(AssetStoreClient.CreateJSONRequestPost(url, dictionary, delegate(AssetStoreResponse ar) { r.Parse(ar); })); }
private void BuildPackage() { AssetStoreAsset.PreviewInfo previewInfo = this.m_Asset.previewInfo; if (previewInfo == null) { return; } if (this.m_BuildAttempts++ > 150) { EditorUtility.DisplayDialog("Building timed out", "Timed out during building of package", "Close"); this.Close(); } else { previewInfo.downloadProgress = -1f; this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.Building; AssetStoreClient.BuildPackage(this.m_Asset, (AssetStoreResultBase <BuildPackageResult> .Callback)(result => { if ((Object)this == (Object)null) { return; } if (result.error != null) { Debug.Log((object)result.error); if (!EditorUtility.DisplayDialog("Error building package", "The server was unable to build the package. Please re-import.", "Ok")) { return; } this.Close(); } else { if (this.m_Asset == null || this.m_Purchasing != AssetStoreInstaBuyWindow.PurchaseStatus.Building || result.packageID != this.m_Asset.packageID) { this.Close(); } string packageUrl = result.asset.previewInfo.packageUrl; if (packageUrl != null && packageUrl != string.Empty) { this.DownloadPackage(); } else { this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.StartBuild; } this.Repaint(); } })); } }
internal static AsyncHTTPClient AssetsInfo(List <AssetStoreAsset> assets, AssetStoreResultBase <AssetStoreAssetsInfo> .Callback callback) { string text = AssetStoreClient.APIUrl("/assets/list"); foreach (AssetStoreAsset current in assets) { text = text + "&id=" + current.id.ToString(); } AssetStoreAssetsInfo r = new AssetStoreAssetsInfo(callback, assets); return(AssetStoreClient.CreateJSONRequest(text, delegate(AssetStoreResponse ar) { r.Parse(ar); })); }
internal static AsyncHTTPClient DirectPurchase(int packageID, string password, AssetStoreResultBase <PurchaseResult> .Callback callback) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type AssetStoreClient.\u003CDirectPurchase\u003Ec__AnonStorey56 purchaseCAnonStorey56 = new AssetStoreClient.\u003CDirectPurchase\u003Ec__AnonStorey56(); string url = AssetStoreClient.APIUrl(string.Format("/purchase/direct/{0}", (object)packageID.ToString())); // ISSUE: reference to a compiler-generated field purchaseCAnonStorey56.r = new PurchaseResult(callback); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary["password"] = password; // ISSUE: reference to a compiler-generated method return(AssetStoreClient.CreateJSONRequestPost(url, dictionary, new AssetStoreClient.DoneCallback(purchaseCAnonStorey56.\u003C\u003Em__94))); }
private void BuildPackage() { AssetStoreAsset.PreviewInfo previewInfo = this.m_Asset.previewInfo; if (previewInfo != null) { if (this.m_BuildAttempts++ > 150) { EditorUtility.DisplayDialog("Building timed out", "Timed out during building of package", "Close"); base.Close(); } else { previewInfo.downloadProgress = -1f; this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.Building; AssetStoreClient.BuildPackage(this.m_Asset, delegate(BuildPackageResult result) { if (!(this == null)) { if (result.error != null) { Debug.Log(result.error); if (EditorUtility.DisplayDialog("Error building package", "The server was unable to build the package. Please re-import.", "Ok")) { base.Close(); } } else { if (this.m_Asset == null || this.m_Purchasing != AssetStoreInstaBuyWindow.PurchaseStatus.Building || result.packageID != this.m_Asset.packageID) { base.Close(); } string packageUrl = result.asset.previewInfo.packageUrl; if (packageUrl != null && packageUrl != "") { this.DownloadPackage(); } else { this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.StartBuild; } base.Repaint(); } } }); } } }
internal static void LoginWithCredentials(string username, string password, bool rememberMe, AssetStoreClient.DoneLoginCallback callback) { if (AssetStoreClient.sLoginState == AssetStoreClient.LoginState.IN_PROGRESS) { Debug.LogError((object)"Tried to login with credentials while already in progress of logging in"); } else { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.IN_PROGRESS; AssetStoreClient.RememberSession = rememberMe; string str = AssetStoreClient.AssetStoreUrl + "/login?skip_terms=1"; AssetStoreClient.sLoginErrorMessage = (string)null; AsyncHTTPClient asyncHttpClient = new AsyncHTTPClient(str.Replace("http://", "https://")); asyncHttpClient.postData = "user="******"&pass="******"X-Unity-Session"] = "26c4202eb475d02864b40827dfff11a14657aa41" + AssetStoreClient.GetToken(); asyncHttpClient.doneCallback = AssetStoreClient.WrapLoginCallback(callback); asyncHttpClient.Begin(); } }
private void DoLogin() { this.m_LoginRemoteMessage = null; if (AssetStoreClient.HasActiveSessionID) { AssetStoreClient.Logout(); } AssetStoreClient.LoginWithCredentials(this.m_Username, this.m_Password, AssetStoreClient.RememberSession, delegate(string errorMessage) { this.m_LoginRemoteMessage = errorMessage; if (errorMessage == null) { base.Close(); } else { base.Repaint(); } }); }
private static AsyncHTTPClient.DoneCallback WrapJsonCallback(AssetStoreClient.DoneCallback callback) { return(delegate(AsyncHTTPClient job) { if (job.IsDone()) { try { AssetStoreResponse response = AssetStoreClient.ParseContent(job); callback(response); } catch (Exception ex) { Debug.Log("Uncaught exception in async net callback: " + ex.Message); Debug.Log(ex.StackTrace); } } }); }
internal static AsyncHTTPClient AssetsInfo(List <AssetStoreAsset> assets, AssetStoreResultBase <AssetStoreAssetsInfo> .Callback callback) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type AssetStoreClient.\u003CAssetsInfo\u003Ec__AnonStorey55 infoCAnonStorey55 = new AssetStoreClient.\u003CAssetsInfo\u003Ec__AnonStorey55(); string url = AssetStoreClient.APIUrl("/assets/list"); using (List <AssetStoreAsset> .Enumerator enumerator = assets.GetEnumerator()) { while (enumerator.MoveNext()) { AssetStoreAsset current = enumerator.Current; url = url + "&id=" + current.id.ToString(); } } // ISSUE: reference to a compiler-generated field infoCAnonStorey55.r = new AssetStoreAssetsInfo(callback, assets); // ISSUE: reference to a compiler-generated method return(AssetStoreClient.CreateJSONRequest(url, new AssetStoreClient.DoneCallback(infoCAnonStorey55.\u003C\u003Em__93))); }
private void DoLogin() { this.m_LoginRemoteMessage = (string)null; if (AssetStoreClient.HasActiveSessionID) { AssetStoreClient.Logout(); } AssetStoreClient.LoginWithCredentials(this.m_Username, this.m_Password, AssetStoreClient.RememberSession, (AssetStoreClient.DoneLoginCallback)(errorMessage => { this.m_LoginRemoteMessage = errorMessage; if (errorMessage == null) { this.Close(); } else { this.Repaint(); } })); }
internal static void LoginWithRememberedSession(AssetStoreClient.DoneLoginCallback callback) { if (AssetStoreClient.sLoginState == AssetStoreClient.LoginState.IN_PROGRESS) { Debug.LogError((object)"Tried to login with remembered session while already in progress of logging in"); } else { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.IN_PROGRESS; if (!AssetStoreClient.RememberSession) { AssetStoreClient.SavedSessionID = string.Empty; } string _toUrl = AssetStoreClient.AssetStoreUrl + "/login?skip_terms=1&reuse_session=" + AssetStoreClient.SavedSessionID; AssetStoreClient.sLoginErrorMessage = (string)null; AsyncHTTPClient asyncHttpClient = new AsyncHTTPClient(_toUrl); asyncHttpClient.header["X-Unity-Session"] = "26c4202eb475d02864b40827dfff11a14657aa41" + AssetStoreClient.GetToken(); asyncHttpClient.doneCallback = AssetStoreClient.WrapLoginCallback(callback); asyncHttpClient.Begin(); } }
public static void RefreshFromServer(AssetStoreAssetSelection.AssetsRefreshed callback) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type AssetStoreAssetSelection.\u003CRefreshFromServer\u003Ec__AnonStorey51 serverCAnonStorey51 = new AssetStoreAssetSelection.\u003CRefreshFromServer\u003Ec__AnonStorey51(); // ISSUE: reference to a compiler-generated field serverCAnonStorey51.callback = callback; if (AssetStoreAssetSelection.s_SelectedAssets.Count == 0) { return; } List <AssetStoreAsset> assets = new List <AssetStoreAsset>(); using (Dictionary <int, AssetStoreAsset> .Enumerator enumerator = AssetStoreAssetSelection.s_SelectedAssets.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <int, AssetStoreAsset> current = enumerator.Current; assets.Add(current.Value); } } // ISSUE: reference to a compiler-generated method AssetStoreClient.AssetsInfo(assets, new AssetStoreResultBase <AssetStoreAssetsInfo> .Callback(serverCAnonStorey51.\u003C\u003Em__8C)); }
internal static AsyncHTTPClient SearchAssets(string searchString, string[] requiredClassNames, string[] assetLabels, List <AssetStoreClient.SearchCount> counts, AssetStoreResultBase <AssetStoreSearchResults> .Callback callback) { string text = string.Empty; string text2 = string.Empty; string text3 = string.Empty; string text4 = string.Empty; foreach (AssetStoreClient.SearchCount current in counts) { text = text + text4 + current.offset; text2 = text2 + text4 + current.limit; text3 = text3 + text4 + current.name; text4 = ","; } if (Array.Exists <string>(requiredClassNames, (string a) => a.Equals("MonoScript", StringComparison.OrdinalIgnoreCase))) { Array.Resize <string>(ref requiredClassNames, requiredClassNames.Length + 1); requiredClassNames[requiredClassNames.Length - 1] = "Script"; } string url = string.Format("{0}&q={1}&c={2}&l={3}&O={4}&N={5}&G={6}", new object[] { AssetStoreClient.APISearchUrl("/search/assets"), Uri.EscapeDataString(searchString), Uri.EscapeDataString(string.Join(",", requiredClassNames)), Uri.EscapeDataString(string.Join(",", assetLabels)), text, text2, text3 }); AssetStoreSearchResults r = new AssetStoreSearchResults(callback); return(AssetStoreClient.CreateJSONRequest(url, delegate(AssetStoreResponse ar) { r.Parse(ar); })); }
internal static void LoginWithRememberedSession(AssetStoreClient.DoneLoginCallback callback) { if (AssetStoreClient.sLoginState == AssetStoreClient.LoginState.IN_PROGRESS) { Debug.LogError("Tried to login with remembered session while already in progress of logging in"); return; } AssetStoreClient.sLoginState = AssetStoreClient.LoginState.IN_PROGRESS; if (!AssetStoreClient.RememberSession) { AssetStoreClient.SavedSessionID = string.Empty; } string toUrl = AssetStoreClient.AssetStoreUrl + "/login?skip_terms=1&reuse_session=" + AssetStoreClient.SavedSessionID; AssetStoreClient.sLoginErrorMessage = null; AsyncHTTPClient asyncHTTPClient = new AsyncHTTPClient(toUrl); asyncHTTPClient.header["X-Unity-Session"] = "26c4202eb475d02864b40827dfff11a14657aa41" + AssetStoreClient.GetToken(); asyncHTTPClient.doneCallback = AssetStoreClient.WrapLoginCallback(callback); asyncHTTPClient.Begin(); }
public void OnGUI() { if (AssetStoreLoginWindow.styles == null) { AssetStoreLoginWindow.styles = new AssetStoreLoginWindow.Styles(); } AssetStoreLoginWindow.LoadLogos(); if (AssetStoreClient.LoginInProgress() || AssetStoreClient.LoggedIn()) { GUI.enabled = false; } GUILayout.BeginVertical(); GUILayout.Space(10f); GUILayout.BeginHorizontal(); GUILayout.Space(5f); GUILayout.Label(AssetStoreLoginWindow.s_AssetStoreLogo, GUIStyle.none, new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUILayout.Label(this.m_LoginReason, EditorStyles.wordWrappedLabel, new GUILayoutOption[0]); Rect lastRect = GUILayoutUtility.GetLastRect(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(6f); Rect rect = new Rect(0.0f, 0.0f, 0.0f, 0.0f); if (this.m_LoginRemoteMessage != null) { Color color = GUI.color; GUI.color = Color.red; GUILayout.Label(this.m_LoginRemoteMessage, EditorStyles.wordWrappedLabel, new GUILayoutOption[0]); GUI.color = color; rect = GUILayoutUtility.GetLastRect(); } float height = (float)((double)lastRect.height + (double)rect.height + 110.0); if (Event.current.type == EventType.Repaint && (double)height != (double)this.position.height) { this.position = new Rect(this.position.x, this.position.y, this.position.width, height); this.Repaint(); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUI.SetNextControlName("username"); this.m_Username = EditorGUILayout.TextField("Username", this.m_Username, new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); this.m_Password = EditorGUILayout.PasswordField("Password", this.m_Password, new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button(new GUIContent("Forgot?", "Reset your password"), AssetStoreLoginWindow.styles.link, new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { Application.OpenURL("https://accounts.unity3d.com/password/new"); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); GUILayout.EndHorizontal(); bool rememberSession = AssetStoreClient.RememberSession; bool flag = EditorGUILayout.Toggle("Remember me", rememberSession, new GUILayoutOption[0]); if (flag != rememberSession) { AssetStoreClient.RememberSession = flag; } GUILayout.EndVertical(); GUILayout.Space(5f); GUILayout.EndHorizontal(); GUILayout.Space(8f); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create account")) { AssetStore.Open("createuser/"); this.m_LoginRemoteMessage = "Cancelled - create user"; this.Close(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel")) { this.m_LoginRemoteMessage = "Cancelled"; this.Close(); } GUILayout.Space(5f); if (GUILayout.Button("Login")) { this.DoLogin(); this.Repaint(); } GUILayout.Space(5f); GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.EndVertical(); if (Event.current.Equals((object)Event.KeyboardEvent("return"))) { this.DoLogin(); this.Repaint(); } if (!(this.m_Username == string.Empty)) { return; } EditorGUI.FocusTextInControl("username"); }
private static AsyncHTTPClient.DoneCallback WrapJsonCallback(AssetStoreClient.DoneCallback callback) { // ISSUE: object of a compiler-generated type is created // ISSUE: reference to a compiler-generated method return new AsyncHTTPClient.DoneCallback(new AssetStoreClient.\u003CWrapJsonCallback\u003Ec__AnonStorey53() { callback = callback }.\u003C\u003Em__90); }
private static AsyncHTTPClient CreateJSONRequestPost(string url, Dictionary<string, string> param, AssetStoreClient.DoneCallback callback) { AsyncHTTPClient asyncHTTPClient = new AsyncHTTPClient(url); asyncHTTPClient.header["X-Unity-Session"] = AssetStoreClient.ActiveOrUnauthSessionID + AssetStoreClient.GetToken(); asyncHTTPClient.postDictionary = param; asyncHTTPClient.doneCallback = AssetStoreClient.WrapJsonCallback(callback); asyncHTTPClient.Begin(); return asyncHTTPClient; }
private void CompletePurchase() { this.m_Message = string.Empty; string password = this.m_Password; this.m_Password = string.Empty; this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.InProgress; AssetStoreClient.DirectPurchase(this.m_Asset.packageID, password, delegate(PurchaseResult result) { this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.Init; if (result.error != null) { this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.Declined; this.m_Message = "An error occured while completing you purhase."; base.Close(); } string text = null; switch (result.status) { case PurchaseResult.Status.BasketNotEmpty: this.m_Message = "Something else has been put in our Asset Store basket while doing this purchase."; this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.Declined; break; case PurchaseResult.Status.ServiceDisabled: this.m_Message = "Single click purchase has been disabled while doing this purchase."; this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.Declined; break; case PurchaseResult.Status.AnonymousUser: this.m_Message = "You have been logged out from somewhere else while doing this purchase."; this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.Declined; break; case PurchaseResult.Status.PasswordMissing: this.m_Message = result.message; base.Repaint(); break; case PurchaseResult.Status.PasswordWrong: this.m_Message = result.message; base.Repaint(); break; case PurchaseResult.Status.PurchaseDeclined: this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.Declined; if (result.message != null) { this.m_Message = result.message; } base.Repaint(); break; case PurchaseResult.Status.Ok: this.m_Purchasing = AssetStoreInstaBuyWindow.PurchaseStatus.Complete; if (result.message != null) { this.m_Message = result.message; } base.Repaint(); break; } if (text != null) { EditorUtility.DisplayDialog("Purchase failed", text + " This purchase has been cancelled.", "Add this item to basket", "Cancel"); } }); Analytics.Track(string.Format("/AssetStore/InstaBuy/{0}/{1}", this.m_Asset.packageID, this.m_Asset.id)); }
internal static void LoginWithCredentials(string username, string password, bool rememberMe, AssetStoreClient.DoneLoginCallback callback) { if (AssetStoreClient.sLoginState == AssetStoreClient.LoginState.IN_PROGRESS) { Debug.LogError("Tried to login with credentials while already in progress of logging in"); return; } AssetStoreClient.sLoginState = AssetStoreClient.LoginState.IN_PROGRESS; AssetStoreClient.RememberSession = rememberMe; string text = AssetStoreClient.AssetStoreUrl + "/login?skip_terms=1"; AssetStoreClient.sLoginErrorMessage = null; AsyncHTTPClient asyncHTTPClient = new AsyncHTTPClient(text.Replace("http://", "https://")); asyncHTTPClient.postData = "user="******"&pass="******"X-Unity-Session"] = "26c4202eb475d02864b40827dfff11a14657aa41" + AssetStoreClient.GetToken(); asyncHTTPClient.doneCallback = AssetStoreClient.WrapLoginCallback(callback); asyncHTTPClient.Begin(); }
private static AsyncHTTPClient.DoneCallback WrapJsonCallback(AssetStoreClient.DoneCallback callback) { return delegate(AsyncHTTPClient job) { if (job.IsDone()) { try { AssetStoreResponse response = AssetStoreClient.ParseContent(job); callback(response); } catch (Exception ex) { Debug.Log("Uncaught exception in async net callback: " + ex.Message); Debug.Log(ex.StackTrace); } } }; }
private static AsyncHTTPClient.DoneCallback WrapLoginCallback(AssetStoreClient.DoneLoginCallback callback) { return delegate(AsyncHTTPClient job) { string text = job.text; if (!job.IsSuccess()) { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; AssetStoreClient.sLoginErrorMessage = ((job.responseCode < 200 || job.responseCode >= 300) ? "Failed to login - please retry" : text); } else { if (text.StartsWith("<!DOCTYPE")) { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; AssetStoreClient.sLoginErrorMessage = "Failed to login"; } else { AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGGED_IN; if (text.Contains("@")) { AssetStoreClient.ActiveSessionID = AssetStoreClient.SavedSessionID; } else { AssetStoreClient.ActiveSessionID = text; } if (AssetStoreClient.RememberSession) { AssetStoreClient.SavedSessionID = AssetStoreClient.ActiveSessionID; } } } callback(AssetStoreClient.sLoginErrorMessage); }; }
void CompletePurchase() { m_Message = ""; string pw = m_Password; m_Password = ""; m_Purchasing = PurchaseStatus.InProgress; AssetStoreClient.DirectPurchase(m_Asset.packageID, pw, delegate(PurchaseResult result) { m_Purchasing = PurchaseStatus.Init; if (result.error != null) { m_Purchasing = PurchaseStatus.Declined; m_Message = "An error occurred while completing you purhase."; Close(); } string msg = null; switch (result.status) { case PurchaseResult.Status.BasketNotEmpty: m_Message = "Something else has been put in our Asset Store basket while doing this purchase."; m_Purchasing = PurchaseStatus.Declined; break; case PurchaseResult.Status.ServiceDisabled: m_Message = "Single click purchase has been disabled while doing this purchase."; m_Purchasing = PurchaseStatus.Declined; break; case PurchaseResult.Status.AnonymousUser: m_Message = "You have been logged out from somewhere else while doing this purchase."; m_Purchasing = PurchaseStatus.Declined; break; case PurchaseResult.Status.PasswordMissing: m_Message = result.message; Repaint(); break; case PurchaseResult.Status.PasswordWrong: m_Message = result.message; Repaint(); break; case PurchaseResult.Status.PurchaseDeclined: m_Purchasing = PurchaseStatus.Declined; if (result.message != null) { m_Message = result.message; } Repaint(); break; case PurchaseResult.Status.Ok: m_Purchasing = PurchaseStatus.Complete; if (result.message != null) { m_Message = result.message; } Repaint(); break; } if (msg != null) { EditorUtility.DisplayDialog("Purchase failed", msg + " This purchase has been cancelled.", "Add this item to basket", "Cancel"); } }); UsabilityAnalytics.Track(string.Format("/AssetStore/InstaBuy/{0}/{1}", m_Asset.packageID, m_Asset.id)); }
private static AsyncHTTPClient CreateJSONRequestDelete(string url, AssetStoreClient.DoneCallback callback) { AsyncHTTPClient asyncHTTPClient = new AsyncHTTPClient(url, "DELETE"); asyncHTTPClient.header["X-Unity-Session"] = AssetStoreClient.ActiveOrUnauthSessionID + AssetStoreClient.GetToken(); asyncHTTPClient.doneCallback = AssetStoreClient.WrapJsonCallback(callback); asyncHTTPClient.Begin(); return asyncHTTPClient; }