void StartCloudBuildAction() { //check if IL2CPP if (ContextForMode[transferModeFlag].BadScriptingBackend()) { EditorUtility.DisplayDialog("Error", "Can't start Cloud Build.\nScripting Backend: IL2CPP detected. To some build targets [Standalone, OSX, Android], IL2CPP is not supported. Please check you player settings.", "OK"); return; } ContextForMode[transferModeFlag].HideProgress(); ContextForMode[transferModeFlag].ResetJobsWithActionsOpened(); JSONNode data = BuildStartCloudBuildOptions(); try { JSONNode response = ucbFacade.PostTask(data); ContextForMode[transferModeFlag].taskId = response["taskUuid"]; ContextForMode[transferModeFlag].taskInfo = response; ContextForMode[transferModeFlag].UpdateSyncTaskInterval(); SaveProjectConfig(); Debug.Log(string.Format(@"Build Task [{0}] started with Jobs [{1}].", ContextForMode[transferModeFlag].taskId, response["jobs"].ToString())); } catch (Exception ex) { Debug.LogError(ex); ShowNotification(new GUIContent(ex.Message)); } }
// // Upload // void StartUploadProject() { SaveGlobalConfig(); //check if IL2CPP if (Utils.IL2CPP()) { EditorUtility.DisplayDialog("Warning", "Scripting Backend: IL2CPP detected. Please notice, to some build targets [Standalone, OSX, Android], IL2CPP is not supported.", "OK"); } try { ContextForMode[transferModeFlag].StartUploadProject(PathHelper.ProjectZipFullPath, ftpInstance); } catch (Exception ex) { if (ex.GetType() == typeof(CosFileExistsException)) { ShowNotification(new GUIContent("File Exists")); } else { Debug.LogError(ex); ShowNotification(new GUIContent("Upload Failed")); } } }
void CancelCloudBuildAction() { if (!string.IsNullOrEmpty(ContextForMode[transferModeFlag].taskId)) { try { ucbFacade.CancelTask(ContextForMode[transferModeFlag].taskId); } catch (Exception ex) { Debug.LogError(ex); ShowNotification(new GUIContent(ex.Message)); } } }
// // Global config // // Save user related information to appdata path of Unity editor. // void SaveGlobalConfig() { try { JSONNode configJson = JSON.Parse("{}"); configJson["ftpHost"] = ftpHost; configJson["ftpPort"] = ftpPort; configJson["ftpUserName"] = ftpUserName; configJson["ftpPassword"] = ftpPassword; configJson["apiHost"] = apiHost; configJson["apiPort"] = apiPort; configJson["cosEndPoint"] = cosEndPoint; File.WriteAllText(PathHelper.GlobalConfigPath, configJson.ToString()); } catch (Exception ex) { Debug.LogError(ex); } }
// // Pack // void StartPackingProject() { OnZipProgressChange(0f); try { ZipHandler.CleanPreviousZip(PathHelper.ZipDirectory); PathHelper.ProjectZipFullPath = ZipHandler.CompressProject(PathHelper.ProjectDirectory, PathHelper.ZipDirectory + "project-pack.zip", new BasicProgress <double>(OnZipProgressChange)); Debug.Log(PathHelper.ProjectZipFullPath); } catch (IOException ex) { //file hash exists Debug.LogError(ex); ShowNotification(new GUIContent(ex.Message)); } finally { EditorUtility.ClearProgressBar(); } }
void LoadProjectConfig() { JSONNode configJson = Utils.GetProjectSettingsJsonNode(); if (configJson == null) { Debug.Info("Load Project Config: Nothing to lowwwwad"); return; } List <string> pDirs = JsonHelper.ToStringList(configJson["PackingDirectories"].AsArray); if (pDirs.Count > 0 && pDirs[0].Contains(PathHelper.ProjectDirectory)) { PackingDirectories.Directories = pDirs; } else { if (pDirs.Count > 0) { Debug.LogError("Failed loading Packing Directories. Please config it again before do Packing."); } PackingDirectories.InitPackingDirectories(); } foreach (TransferMode t in Enum.GetValues(typeof(TransferMode))) { int modeInt = (int)t; string modeString = Enum.GetName(typeof(TransferMode), t); ContextForMode[modeInt].taskId = configJson["taskId"][modeString]; ContextForMode[modeInt].repoUsername = configJson["repoInfo"][modeString]["repoUsername"]; ContextForMode[modeInt].repoPassword = configJson["repoInfo"][modeString]["repoPassword"]; ContextForMode[modeInt].repoUrl = configJson["repoInfo"][modeString]["repoUrl"]; ContextForMode[modeInt].repoBranch = configJson["repoInfo"][modeString]["repoBranch"]; ContextForMode[modeInt].repoToken = configJson["repoInfo"][modeString]["repoToken"]; } }
// // Life cycle // private void OnEnable() { guiDefaultColor = GUI.color; autoRepaintOnSceneChange = true; minSize = new Vector2(350, 650); try { GetLatestZip(); LoadProjectConfig(); LoadGlobalConfig(); } catch (Exception ex) { Debug.LogError(ex); } showExtraFields_Upload = new AnimBool(true); showExtraFields_Upload.valueChanged.AddListener(Repaint); SyncBuildTaskInfo(); }
bool IsBuildJobDone(int index) { if (ContextForMode[transferModeFlag].taskInfo == null || ContextForMode[transferModeFlag].taskInfo["jobs"].IsNull) { return(false); } bool result = false; try { int status = (int)Enum.Parse(typeof(JobStatus), ContextForMode[transferModeFlag].taskInfo["jobs"][index]["status"]); if (status > (int)JobStatus.RUNNING && status != (int)JobStatus.CANCELLED) { result = true; } } catch (Exception ex) { Debug.LogError(ex); } return(result); }