/// <summary> /// 标题GUI /// </summary> private void OnTitleGUI() { GUILayout.BeginHorizontal(EditorStyles.toolbar); if (GUILayout.Button(_showModuleType.ToString(), EditorStyles.toolbarDropDown)) { GenericMenu gm = new GenericMenu(); gm.AddItem(new GUIContent("All Module"), _showModuleType == ModuleType.AllModule, () => { _showModuleType = ModuleType.AllModule; CurrentModule = null; _currentEditModule = null; }); gm.AddItem(new GUIContent("In Project"), _showModuleType == ModuleType.InProject, () => { _showModuleType = ModuleType.InProject; CurrentModule = null; _currentEditModule = null; }); gm.ShowAsContext(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Git Bash", EditorStyles.toolbarButton)) { GitBashWindow.OpenWindow(this); } if (GUILayout.Button("Credentials", EditorStyles.toolbarButton)) { CredentialsProviderWindow.OpenWindow(this, _modulesLibrary.SetCredentials); } if (GUILayout.Button(_helpGC, "IconButton")) { Application.OpenURL("https://wanderer.blog.csdn.net/article/details/109488065"); } GUILayout.EndHorizontal(); }
/// <summary> /// 模块GUI /// </summary> private void OnModuleGUI() { if (CurrentModule == null) { return; } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label(CurrentModule.Name, "LargeBoldLabel"); GUILayout.Space(10); GUI.color = (CurrentModule.BranchName == "(no branch)" || CurrentModule.BranchName == "<None>") ? Color.red : Color.cyan; GUILayout.Label("Branch: [" + CurrentModule.BranchName + "]", "LargeBoldLabel"); GUI.color = Color.white; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUI.enabled = CurrentModule.IsLocalExist; if (GUILayout.Button("Local", "ButtonLeft")) { ProcessStartInfo psi = new ProcessStartInfo(CurrentModule.Path); Process.Start(psi); } GUI.enabled = CurrentModule.IsRemoteExist; if (GUILayout.Button("Remote", "ButtonRight")) { Application.OpenURL(CurrentModule.RemotePath); } GUI.enabled = !CurrentModule.IsLocalExist && CurrentModule.IsRemoteExist; if (GUILayout.Button("Download", "ButtonLeft")) { _modulesLibrary.Clone(CurrentModule, () => { AssetDatabase.Refresh(); }); } GUI.enabled = CurrentModule.IsLocalExist && CurrentModule.IsRemoteExist; if (GUILayout.Button("Update", "ButtonRight")) { _modulesLibrary.Pull(CurrentModule, () => { AssetDatabase.Refresh(); }); } GUI.backgroundColor = Color.green; if (GUILayout.Button(_gitBashGC)) { string gitBashPath = EditorPrefs.GetString(Utility.GitBashPath, ""); if (string.IsNullOrEmpty(gitBashPath) || !File.Exists(gitBashPath)) { Utility.LogError("Open GitBash failed! please set the GitBash.exe path!"); GitBashWindow.OpenWindow(this); } else { Process process = new Process(); process.StartInfo = new ProcessStartInfo(gitBashPath, "\"--cd=" + CurrentModule.Path + "\""); process.Start(); } } GUI.backgroundColor = Color.white; GUI.enabled = true; if (_currentModuleLICENSE != null) { GUI.backgroundColor = Color.yellow; if (GUILayout.Button("LICENSE")) { EditorGUIUtility.PingObject(_currentModuleLICENSE); } GUI.backgroundColor = Color.white; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Local Path", GUILayout.Width(80), GUILayout.Height(20)); GUILayout.Label(CurrentModule.Path, "Badge", GUILayout.Height(20)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Label("Remote Path", GUILayout.Width(80), GUILayout.Height(20)); GUIContent remoteGC = GetRemoteTypeGC(CurrentModule); remoteGC.text = CurrentModule.RemotePath; GUILayout.Label(remoteGC, "Badge", GUILayout.Height(20)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); if (CurrentModule.IsLocalExist) { if (_currentModuleReadme != null) { GUILayout.BeginHorizontal(); GUILayout.Label("README.md", "LargeBoldLabel"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); _moduleScroll = GUILayout.BeginScrollView(_moduleScroll, "HelpBox"); GUILayout.Label(_currentModuleReadme.text); GUILayout.EndScrollView(); } } else { EditorGUILayout.HelpBox("There is no this module locally! please download to local first.", MessageType.Warning); } GUILayout.EndVertical(); }