public static void GetMetaData(AssetStorePublisher account, PackageDataSource packageDataSource, AssetStoreAPI.DoneCallback callback) { AssetStoreClient.CreatePendingGet("metadata", "/metadata/0", delegate(AssetStoreResponse res) { DebugUtils.Log(res.data); string errorMessage; JSONValue jval; bool flag = AssetStoreAPI.Parse(res, out errorMessage, out jval); if (flag && !jval.ContainsKey("error_fields")) { callback(errorMessage); return; } string str = "none"; try { str = "account"; string text = AssetStoreAPI.OnAssetStorePublisher(jval, account, packageDataSource); if (text != null) { callback(text); return; } } catch (JSONTypeException ex) { callback("Malformed metadata response from server: " + str + " - " + ex.Message); } catch (KeyNotFoundException ex2) { callback("Malformed metadata response from server. " + str + " - " + ex2.Message); } callback(null); }); }
public static void UploadAssets(Package package, string newGUID, string newRootPath, string newProjectpath, string filepath, AssetStoreAPI.DoneCallback callback, AssetStoreClient.ProgressCallback progress) { string path = string.Format("/package/{0}/unitypackage", package.versionId); AssetStoreClient.UploadLargeFile(path, filepath, new Dictionary <string, string> { { "root_guid", newGUID }, { "root_path", newRootPath }, { "project_path", newProjectpath } }, delegate(AssetStoreResponse resp) { if (resp.HttpStatusCode == -2) { callback("aborted"); return; } string errorMessage = null; JSONValue jsonvalue; AssetStoreAPI.Parse(resp, out errorMessage, out jsonvalue); callback(errorMessage); }, progress); }
public static void UploadBundle(string path, string filepath, AssetStoreAPI.UploadBundleCallback callback, AssetStoreClient.ProgressCallback progress) { AssetStoreClient.UploadLargeFile(path, filepath, null, delegate(AssetStoreResponse resp) { string errorMessage = null; JSONValue jsonvalue; AssetStoreAPI.Parse(resp, out errorMessage, out jsonvalue); callback(filepath, errorMessage); }, progress); }
private static void Upload(string path, string filepath, AssetStoreAPI.DoneCallback callback, AssetStoreClient.ProgressCallback progress = null) { AssetStoreClient.Pending pending = AssetStoreClient.CreatePendingUpload(path, path, filepath, delegate(AssetStoreResponse resp) { string errorMessage = null; JSONValue jsonvalue; AssetStoreAPI.Parse(resp, out errorMessage, out jsonvalue); callback(errorMessage); }); pending.progressCallback = progress; }
private void UploadPackage() { DebugUtils.Log("UploadPackage"); this.m_AssetsState = AssetStorePackageController.AssetsState.UploadingPackage; if (string.IsNullOrEmpty(this.m_DraftAssetsPath)) { DebugUtils.LogError("No assets to upload has been selected"); this.m_AssetsState = AssetStorePackageController.AssetsState.None; return; } AssetStoreAPI.UploadAssets(this.m_Package, this.m_LocalRootGUID, this.m_LocalRootPath, this.m_LocalProjectPath, this.m_DraftAssetsPath, new AssetStoreAPI.DoneCallback(this.OnAssetsUploaded), new AssetStoreClient.ProgressCallback(this.OnAssetsUploading)); }
public void UploadAllAssetBundles() { this.m_PendingUploadsAssetPath = this.m_AssetBundleFiles.Keys.ToList <string>(); this.m_MainAssetsProgress = new List <double>(this.m_MainAssets.Count); this.m_ErrorMessages = null; this.m_ProgressDirty = false; this.m_CachedProgressValue = 0.0; foreach (string text in this.m_PendingUploadsAssetPath) { string filepath = this.m_AssetBundleFiles[text]; string uploadBundlePath = AssetStoreAPI.GetUploadBundlePath(this.m_AssetStorePackageController.SelectedPackage, text); AssetStoreAPI.UploadBundle(uploadBundlePath, filepath, new AssetStoreAPI.UploadBundleCallback(this.OnFinishUploadBundle), this.OnBundleProgress(text)); this.m_MainAssetsProgress.Add(0.0); } }
private void RefreshPackages() { this.Account.mStatus = AssetStorePublisher.Status.Loading; AssetStoreAPI.GetMetaData(this.Account, this.m_PackageDataSource, delegate(string errMessage) { if (errMessage != null) { Debug.LogError("Error fetching metadata: " + errMessage); LoginWindow.Logout(); AssetStoreManager.Login("To upload packages, please log in to your Asset Store Publisher account."); this.Repaint(); return; } this.m_PackageController.AutoSetSelected(this); this.Repaint(); }); }
private static void OnPackages(JSONValue jv, PackageDataSource packageDataSource) { IList <Package> allPackages = packageDataSource.GetAllPackages(); Dictionary <string, JSONValue> dictionary = jv.AsDict(false); string text = string.Empty; foreach (KeyValuePair <string, JSONValue> keyValuePair in dictionary) { int num = int.Parse(keyValuePair.Key); JSONValue value = keyValuePair.Value; Package package = packageDataSource.FindByID(num); if (package == null) { package = new Package(num); } text += AssetStoreAPI.OnPackageReceived(value, package); text += AssetStoreAPI.RefreshMainAssets(value, package); allPackages.Add(package); } packageDataSource.OnDataReceived(text); }
private static string OnAssetStorePublisher(JSONValue jval, AssetStorePublisher account, PackageDataSource packageDataSource) { string str = "unknown field"; try { str = "publisher"; Dictionary <string, JSONValue> dictionary = jval["publisher"].AsDict(false); account.mStatus = AssetStorePublisher.Status.New; if (dictionary.ContainsKey("name")) { account.mStatus = AssetStorePublisher.Status.Existing; str = "publisher -> id"; account.publisherId = int.Parse(dictionary["id"].AsString(false)); str = "publisher -> name"; account.publisherName = dictionary["name"].AsString(false); } str = "publisher"; if (AssetStoreManager.sDbg) { DebugUtils.Log("publisher " + jval["publisher"].ToString(string.Empty, " ")); DebugUtils.Log("packs " + jval["packages"].ToString(string.Empty, " ")); } str = "packages"; if (!jval.Get("packages").IsNull()) { AssetStoreAPI.OnPackages(jval["packages"], packageDataSource); } } catch (JSONTypeException ex) { return("Malformed response from server: " + str + " - " + ex.Message); } catch (KeyNotFoundException ex2) { return("Malformed response from server. " + str + " - " + ex2.Message); } return(null); }
private void RenderDebug() { if (AssetStoreManager.sDbgButtons) { GUILayout.FlexibleSpace(); GUILayout.Label("Debug: ", AssetStoreManager.Styles.ToolbarLabel, new GUILayoutOption[0]); if (GUILayout.Button("FileSelector", EditorStyles.toolbarButton, new GUILayoutOption[0])) { FileSelector.Show("/", new List <string>(), delegate(List <string> newList) { foreach (string str in newList) { DebugUtils.Log(str); } }); } if (GUILayout.Button("Reload", EditorStyles.toolbarButton, new GUILayoutOption[0])) { AssetStoreAPI.GetMetaData(this.Account, this.m_PackageDataSource, delegate(string errMessage) { if (errMessage != null) { Debug.LogError("Error fetching metadata: " + errMessage); LoginWindow.Logout(); AssetStoreManager.Login("Login to fetch current list of published packages"); base.Repaint(); return; } this.m_PackageController.AutoSetSelected(this); base.Repaint(); }); } if (GUILayout.Button("Logout", EditorStyles.toolbarButton, new GUILayoutOption[0])) { AssetStoreClient.Logout(); } } }
private void RenderMenu() { GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]); GUILayout.FlexibleSpace(); this.RenderToolbar(); GUILayout.EndHorizontal(); bool flag = false; if (!LoginWindow.IsLoggedIn) { if (!LoginWindow.IsVisible) { LoginWindow.Login("To upload packages, please log in to your Asset Store Publisher account.", new LoginWindow.LoginCallback(AssetStoreManager.OnLoggedIn), GUIUtil.RectOnRect(360f, 180f, base.position)); } GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Space(10f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(GUIUtil.StatusWheel, new GUILayoutOption[0]); GUILayout.Label("Please login", new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } else { if (this.Account.mStatus == AssetStorePublisher.Status.NotLoaded) { this.Account.mStatus = AssetStorePublisher.Status.Loading; AssetStoreAPI.GetMetaData(this.Account, this.m_PackageDataSource, delegate(string errMessage) { if (errMessage != null) { Debug.LogError("Error fetching metadata: " + errMessage); LoginWindow.Logout(); AssetStoreManager.Login("To upload packages, please log in to your Asset Store Publisher account.", "Account is not registered as a Publisher. \nPlease create a Publisher ID."); this.Repaint(); return; } this.m_PackageController.AutoSetSelected(this); this.Repaint(); }); } if (this.Account.mStatus == AssetStorePublisher.Status.NotLoaded || this.Account.mStatus == AssetStorePublisher.Status.Loading) { GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Space(10f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(GUIUtil.StatusWheel, new GUILayoutOption[0]); GUILayout.Label("Fetching account information", new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); this.Repaint(); } else { bool enabled = GUI.enabled; if (this.Account.mStatus != AssetStorePublisher.Status.Existing) { GUI.enabled = false; } GUI.enabled = enabled; flag = true; } } if (!flag && this.m_PackageController.SelectedPackage != null) { this.m_PackageController.SelectedPackage = null; } }