private void RefreshPackages() { this.Account.mStatus = AssetStorePublisher.Status.Loading; AssetStoreAPI.GetMetaData(this.Account, this.m_PackageDataSource, (string errMessage) => { if (errMessage == null) { this.m_PackageController.AutoSetSelected(this); this.Repaint(); return; } Debug.LogError(string.Concat("Error fetching metadata: ", errMessage)); LoginWindow.Logout(); AssetStoreManager.Login("To upload packages, please log in to your Asset Store Publisher account."); this.Repaint(); }); }
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 current in newList) { DebugUtils.Log(current); } }); } 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 (this.Account.mStatus == AssetStorePublisher.Status.NotLoaded) { this.Account.mStatus = AssetStorePublisher.Status.Loading; AssetStoreAPI.GetMetaData(this.Account, this.m_PackageDataSource, (string errMessage) => { if (errMessage == null) { this.m_PackageController.AutoSetSelected(this); this.Repaint(); return; } Debug.LogError(string.Concat("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(); }); } 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 flag1 = GUI.enabled; if (this.Account.mStatus != AssetStorePublisher.Status.Existing) { GUI.enabled = false; } GUI.enabled = flag1; flag = true; } } else { 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(); } if (!flag && this.m_PackageController.SelectedPackage != null) { this.m_PackageController.SelectedPackage = null; } }
private void RenderMenu() { GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]); GUILayout.FlexibleSpace(); this.RenderDebug(); GUILayout.EndHorizontal(); bool flag = false; if (!LoginWindow.IsLoggedIn) { if (!LoginWindow.IsVisible) { LoginWindow.Login("Please re-login to asset store in order to fetch publisher details", new LoginWindow.LoginCallback(AssetStoreManager.OnLoggedIn), GUIUtil.RectOnRect(360f, 140f, 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("Login to fetch current list of published packages"); base.Repaint(); return; } this.m_PackageController.AutoSetSelected(this); base.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(); base.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; } }
/// <summary> /// Upload a package, using the specified options. /// </summary> /// <param name="username">The username credentials to use for package uploading.</param> /// <param name="password">The password credentials to use for package uploading.</param> /// <param name="packageName">The package name. The package must be set to draft status in the Publisher Administration.</param> /// <param name="rootPath">The root path of the package (relative to Application.dataPath). If null, use the project Assets folder.</param> /// <param name="mainAssets">An array of the main assets for the package (relative to Application.dataPath). If null, do not upload or change any main assets.</param> /// <param name="loginTimeout">The maximum amount of time to wait (in seconds) when logging in. Defaults to 90 seconds. Must be within 2 and 36000 seconds. Login is attempted twice.</param> /// <param name="metadataTimeout">The maximum amount of time to wait (in seconds) when getting metadata. Defaults to 600 seconds. Must be within 2 and 36000 seconds.</param> /// <param name="uploadTimeout">The maximum amount of time to wait (in seconds) when uploading. Defaults to 36000 seconds. Must be within 2 and 36000 seconds.</param> public static void UploadAssetStorePackage(string username, string password, string packageName, string rootPath = null, string[] mainAssets = null, int loginTimeout = 90, int metadataTimeout = 600, int uploadTimeout = 36000, bool skipProjectSettings = false, bool actuallyUpload = false, string outputPath = "") { if (string.IsNullOrEmpty(username)) { throw new ArgumentNullException("username"); } if (string.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } if (string.IsNullOrEmpty(packageName)) { throw new ArgumentNullException("packageName"); } s_Username = username; s_Password = password; s_PackageName = packageName; s_RootPath = rootPath; s_MainAssets = mainAssets; s_LoginTimeout = Mathf.Clamp(loginTimeout, 2, 36000); s_MetadataTimeout = Mathf.Clamp(metadataTimeout, 2, 36000); s_UploadTimeout = Mathf.Clamp(uploadTimeout, 2, 36000); s_SkipProjectSettings = skipProjectSettings; Finish(); #if !UNITY_5_5_OR_NEWER if (Application.webSecurityEnabled) { Debug.Log("[Asset Store Batch Mode] Switching from Web Player platform..."); EditorUserBuildSettings.SwitchActiveBuildTarget(EditorUserBuildSettings.selectedStandaloneTarget); } #endif Debug.Log("[Asset Store Batch Mode] Logging into the Asset Store..."); AssetStoreClient.LoginWithCredentials(s_Username, s_Password, false, OnLogin); if (!WaitForUpdate(ref s_LoginDone, s_LoginTimeout)) { Finish(); // Try again s_LoginDone = false; AssetStoreClient.LoginWithCredentials(s_Username, s_Password, false, OnLogin); if (!WaitForUpdate(ref s_LoginDone, s_LoginTimeout)) { Finish(); return; } } AssetStoreAPI.GetMetaData(s_PublisherAccount, s_PackageDataSource, OnGetMetadata); Debug.Log("[Asset Store Batch Mode] Getting package metadata..."); if (!WaitForUpdate(ref s_GetMetadataDone, s_MetadataTimeout)) { Finish(); return; } var packages = s_PackageDataSource.GetAllPackages(); var package = packages.FirstOrDefault(p => p.Name == s_PackageName && p.Status == Package.PublishedStatus.Draft); if (package == null) { Debug.LogError("[Asset Store Batch Mode] Draft package: " + s_PackageName + " not found!"); Finish(); return; } // Validate root project folder var projectFolder = Path.Combine(Application.dataPath, s_RootPath ?? string.Empty); // Convert to unix path style projectFolder = projectFolder.Replace("\\", "/"); if (!IsValidProjectFolder(projectFolder)) { Debug.LogError("[Asset Store Batch Mode] Project folder is invalid"); Finish(); return; } // Set root asset path var localRootPath = SetRootPath(package, projectFolder); // Set main assets if (MainAssetsUtil.CanGenerateBundles) { // TODO: Set main assets } // Verify content var checkContent = CheckContent(package, localRootPath); if (!string.IsNullOrEmpty(checkContent)) { Debug.LogError("[Asset Store Batch Mode] " + checkContent); Finish(); return; } var draftAssetsPath = GetDraftAssetsPath(localRootPath); Export(package, localRootPath, draftAssetsPath, outputPath); if (actuallyUpload) { // Upload assets AssetStoreAPI.UploadAssets( package, AssetStorePackageController.GetLocalRootGUID(package), localRootPath, Application.dataPath, draftAssetsPath, OnAssetsUploaded, null); Debug.Log("[Asset Store Batch Mode] Uploading asset..."); if (!WaitForUpdate(ref s_AssetsUploadedDone, s_UploadTimeout)) { Finish(); return; } if (MainAssetsUtil.CanGenerateBundles) { // TODO: Upload main assets } Debug.Log("[Asset Store Batch Mode] Asset successfully uploaded"); } Finish(); }