Example #1
0
 public UcbSessionQCloudCredentialProvider(
     string tmpSecretId,
     string tmpSecretKey,
     long tmpExpiredTime,
     string sessionToken,
     string projectId,
     UcbFacade ucbFacade)
     : this(tmpSecretId, tmpSecretKey, tmpExpiredTime, sessionToken)
 {
     this.projectId = projectId;
     this.ucbFacade = ucbFacade;
 }
Example #2
0
        public static void showWindow()
        {
            Debug.Log("Unity Version: " + unityVersion);

            if (UcbFacade.GetInstance().CheckUnityVersion(unityVersion))
            {
                EditorWindow.GetWindow(typeof(UcbEditorWindow));
            }
            else
            {
                EditorUtility.DisplayDialog("Unsupported Unity Version",
                                            "You are using a version of Unity Editor that is not supported by Cloud Build Plugin.", "OK");
            }
        }
Example #3
0
        //
        // UI
        //
        void OnGUI()
        {
            scrollPos =
                EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height));

            EditorGUILayout.LabelField("Mode", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            int newMode = EditorGUILayout.Popup("Cloud Build Mode:",
                                                transferModeFlag, transferModeOptions, EditorStyles.popup);

            if (newMode != transferModeFlag)
            {
                transferModeFlag = newMode;
                OnTransferModeChange();
            }

            if (TransferMode.FTP.Equals(ContextForMode[transferModeFlag].transferMode))
            {
                EditorGUILayout.LabelField("* for internal use only");
            }
            EditorGUI.indentLevel--;

            //
            // Upload
            //
            if (TransferModeUtils.IsRepository(transferModeFlag))
            {
                EditorGUILayout.Separator();
                EditorGUI.indentLevel++;
                ContextForMode[transferModeFlag].repoUrl = EditorGUILayout.TextField("Repository URL:", ContextForMode[transferModeFlag].repoUrl);
                if (transferModeFlag == (int)TransferMode.GIT)
                {
                    ContextForMode[transferModeFlag].repoBranch = EditorGUILayout.TextField("Branch name:", ContextForMode[transferModeFlag].repoBranch);

                    gitCredentialModeFlag = EditorGUILayout.Popup("Credential Mode:",
                                                                  gitCredentialModeFlag, gitCredentialOptions, EditorStyles.popup);
                }

                ContextForMode[transferModeFlag].relativePath = EditorGUILayout.TextField(new GUIContent("Relative Path (?):", "Unity project path relative to repository root"), ContextForMode[transferModeFlag].relativePath);

                if (transferModeFlag == (int)TransferMode.GIT && gitCredentialModeFlag == (int)GitCredentialMode.GitToken)
                {
                    ContextForMode[transferModeFlag].repoToken = EditorGUILayout.TextField("Git Token:", ContextForMode[transferModeFlag].repoToken);
                }
                else
                {
                    ContextForMode[transferModeFlag].repoUsername = EditorGUILayout.TextField("Repo Username:"******"Repo Password:"******"Upload", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;
                GUIStyle wraptStyle = new GUIStyle(EditorStyles.label);
                wraptStyle.wordWrap = true;
                EditorGUILayout.LabelField("* Remember to config Build-Settings for your build target(s), and SAVE project before packing.", wraptStyle);

                if (GUILayout.Button("Config Packing Directories"))
                {
                    UcbPackDirectoriesWindow.showWindow();
                }

                if (GUILayout.Button("Pack"))
                {
                    if (UcbFacade.GetInstance().CheckUnityVersion(unityVersion))
                    {
                        StartPackingProject();
                    }
                    else
                    {
                        ShowNotification(new GUIContent("Unsupported Unity version"));
                    }
                }
                if (!string.IsNullOrEmpty(PathHelper.ProjectZipFullPath))
                {
                    EditorGUILayout.LabelField("Latest Local Pack:", File.GetLastWriteTime(PathHelper.ProjectZipFullPath).ToString());
                }

                if (transferModeFlag == (int)TransferMode.FTP)
                {
                    ftpHost     = EditorGUILayout.TextField("FTP Host:", ftpHost);
                    ftpPort     = EditorGUILayout.TextField("FTP Port:", ftpPort);
                    ftpUserName = EditorGUILayout.TextField("FTP Username:"******"FTP Password:"******"Upload Mode:",
                                                                                               ContextForMode[transferModeFlag].cosUploadModeFlag, cosUploadModeOptions, EditorStyles.popup);
                }

                string uploadBtnText = "Upload";
                if (ContextForMode[transferModeFlag].isUploading || string.IsNullOrEmpty(PathHelper.ProjectZipFullPath))
                {
                    GUI.enabled = false;
                    if (ContextForMode[transferModeFlag].isUploading)
                    {
                        uploadBtnText = "Uploading...";
                    }
                }

                if (GUILayout.Button(uploadBtnText))
                {
                    StartUploadProject();
                }

                GUI.enabled = true;

                EditorGUI.indentLevel--;
            }
            //
            // Build
            //
            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Build", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            string latestBuildTime = GetLatestBuildTimeString();

            EditorGUILayout.LabelField("Select Build Target(s)");
            EditorGUI.indentLevel++;
            for (int i = 0; i < ContextForMode[transferModeFlag].buildTargetSelection.Length; i++)
            {
                string buildTargetName = Enum.GetNames(typeof(BuildTarget))[i];
                Rect   statusRect      = EditorGUILayout.BeginHorizontal(GUILayout.Width(290));
                EditorGUILayout.LabelField(buildTargetName);
                ContextForMode[transferModeFlag].buildTargetSelection[i] = EditorGUILayout.Toggle(ContextForMode[transferModeFlag].buildTargetSelection[i]);
                EditorGUILayout.EndHorizontal();
            }
            EditorGUI.indentLevel--;

            if (ContextForMode[transferModeFlag].IsBuildTaskRunning())
            {
                if (GUILayout.Button("Cancel Cloud Build"))
                {
                    CancelCloudBuildAction();
                }
            }
            else
            {
                if (GUILayout.Button("Start Cloud Build"))
                {
                    if (!TransferModeUtils.IsRepository(transferModeFlag) && !ContextForMode[transferModeFlag].projectUploaded)
                    {
                        ShowNotification(new GUIContent("No Project Uploaded"));
                    }
                    else if (!IsBuildTargetSelected())
                    {
                        ShowNotification(new GUIContent("Select Build Target"));
                    }
                    else
                    {
                        StartCloudBuildAction();
                    }
                }
            }

            if (!string.IsNullOrEmpty(latestBuildTime))
            {
                EditorGUILayout.LabelField("Latest Build:", latestBuildTime);
            }

            if (string.IsNullOrEmpty(ContextForMode[transferModeFlag].taskId) || ContextForMode[transferModeFlag].taskInfo == null)
            {
                EditorGUILayout.LabelField("Build Status", "Not Started");
            }
            else
            {
                EditorGUILayout.LabelField("Build Status");
                EditorGUI.indentLevel++;
                JSONArray jobs = ContextForMode[transferModeFlag].taskInfo["jobs"].AsArray;
                for (int i = 0; i < jobs.Count; i++)
                {
                    string statusString = jobs[i]["status"];
                    if (statusString == "FAILED")
                    {
                        GUI.color = new Color(255, 0, 0);
                    }
                    Rect statusRect = EditorGUILayout.BeginHorizontal(GUILayout.Width(290));
                    EditorGUILayout.LabelField(jobs[i]["buildTarget"], GUILayout.Width(170));
                    EditorGUILayout.LabelField(statusString, GUILayout.Width(100));
                    GUI.color = guiDefaultColor;

                    if (IsBuildJobDone(i))
                    {
                        if (GUILayout.Button("Actions", GUILayout.Width(60), GUILayout.Height(14)))
                        {
                            if (!ContextForMode[transferModeFlag].jobActionOpened.ContainsKey(jobs[i]["name"]))
                            {
                                ContextForMode[transferModeFlag].jobActionOpened[jobs[i]["name"]] = true;
                            }
                            else
                            {
                                ContextForMode[transferModeFlag].jobActionOpened[jobs[i]["name"]] =
                                    !ContextForMode[transferModeFlag].jobActionOpened[jobs[i]["name"]];
                            }
                        }
                    }

                    EditorGUILayout.EndHorizontal();

                    if (ContextForMode[transferModeFlag].jobActionOpened.ContainsKey(jobs[i]["name"]) &&
                        ContextForMode[transferModeFlag].jobActionOpened[jobs[i]["name"]] == true)
                    {
                        //download button group
                        try
                        {
                            if (jobs[i]["downloadLink"] != null)
                            {
                                if (GUILayout.Button("Download"))
                                {
                                    Application.OpenURL(jobs[i]["downloadLink"]);
                                    EditorUtility.ClearProgressBar();
                                }
                                if (GUILayout.Button("Copy Download URL"))
                                {
                                    EditorGUIUtility.systemCopyBuffer = jobs[i]["downloadLink"];
                                    ShowNotification(new GUIContent("Copied URL" + Environment.NewLine +
                                                                    " to clipboard"));
                                    EditorUtility.ClearProgressBar();
                                }

                                if (jobs[i]["downloadLink"].ToString().Contains(".apk"))
                                {
                                    if (GUILayout.Button("QR Code"))
                                    {
                                        UcbQrPopup.Open(jobs[i]["downloadLink"], "Cloud Build Download Apk", "Scan QR code to download apk" + Environment.NewLine + "direct into your mobile devices");
                                    }
                                }
                            }
                            //
                            //build just finished
                            //
                            if (jobs[i]["exectionLog"] != null || jobs[i]["logLink"] != null)
                            {
                                if (GUILayout.Button("Print Log"))
                                {
                                    ShowNotification(new GUIContent("Printed to" + Environment.NewLine + "console"));
                                    if (jobs[i]["exectionLog"] != null)
                                    {
                                        Debug.Info("Build Execution Log :" + jobs[i]["exectionLog"]);
                                    }
                                    if (jobs[i]["logLink"] != null)
                                    {
                                        Debug.Info("Editor Log in Link:" + jobs[i]["logLink"]);
                                        Debug.Info("Editor Log Content:" + ftpInstance.GetEditorLog(jobs[i]["logLink"]));
                                    }
                                }
                                EditorGUILayout.Separator();
                            }
                        }
                        catch (NullReferenceException ex)
                        {
                        }
                    }
                }
                EditorGUI.indentLevel--;
            }
            if (ContextForMode[transferModeFlag].taskId != null)
            {
                if (GUILayout.Button("Track This Task by WeChat"))
                {
                    string url = Constants.WEAPP_QR_PREFIX + ContextForMode[transferModeFlag].taskId;
                    UcbQrPopup.Open(url, "QR for WeApp Monitor", "Scan QR code by WeChat" + Environment.NewLine + "to monitor this task");
                }
            }

            EditorGUI.indentLevel--;
            if (ContextForMode[transferModeFlag].isProgressBarVisible)
            {
                string text = ContextForMode[transferModeFlag].progressTitle;
                if (1 - ContextForMode[transferModeFlag].progressValue > 0.0001)
                {
                    text += String.Format(" [ {0}% ]", (int)(ContextForMode[transferModeFlag].progressValue * 100));
                }

                EditorGUI.ProgressBar(new Rect(3, position.height - 30, position.width - 6, 20),
                                      ContextForMode[transferModeFlag].progressValue, text);
            }


            EditorGUILayout.Separator();
            GUIStyle foldOutStyle = new GUIStyle(EditorStyles.foldout);

            foldOutStyle.fontStyle = FontStyle.Bold;
            showAdvancedSettings   = EditorGUILayout.Foldout(showAdvancedSettings, "Advanced Settings", foldOutStyle);
            if (showAdvancedSettings)
            {
                EditorGUI.indentLevel++;
                apiHost     = EditorGUILayout.TextField("API Host:", apiHost);
                apiPort     = EditorGUILayout.TextField("API Port:", apiPort);
                cosEndPoint = EditorGUILayout.TextField("COS Host:", cosEndPoint);
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.EndScrollView();
        }
Example #4
0
 public void SetUcbFacade(string projectId, UcbFacade ucbFacade)
 {
     this.projectId = projectId;
     this.ucbFacade = ucbFacade;
 }