暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DrawGuiModeSwitcher.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using UnityEditor;
  2. using UnityEditor.IMGUI.Controls;
  3. using UnityEngine;
  4. using Unity.PlasticSCM.Editor.Views.PendingChanges;
  5. namespace Unity.PlasticSCM.Editor
  6. {
  7. internal static class DrawGuiModeSwitcher
  8. {
  9. internal static void ForMode(
  10. bool isGluonMode,
  11. WorkspaceWindow workspaceWindow,
  12. TreeView changesTreeView,
  13. EditorWindow editorWindow)
  14. {
  15. GUI.enabled = !workspaceWindow.IsOperationInProgress();
  16. EditorGUI.BeginChangeCheck();
  17. GuiMode currentMode = isGluonMode ?
  18. GuiMode.GluonMode : GuiMode.DeveloperMode;
  19. GuiMode selectedMode = (GuiMode)EditorGUILayout.EnumPopup(
  20. currentMode,
  21. EditorStyles.toolbarDropDown,
  22. GUILayout.Width(100));
  23. if (EditorGUI.EndChangeCheck())
  24. {
  25. SwitchGuiModeIfUserWants(
  26. workspaceWindow, currentMode, selectedMode,
  27. changesTreeView, editorWindow);
  28. }
  29. GUI.enabled = true;
  30. }
  31. static void SwitchGuiModeIfUserWants(
  32. WorkspaceWindow workspaceWindow,
  33. GuiMode currentMode, GuiMode selectedMode,
  34. TreeView changesTreeView,
  35. EditorWindow editorWindow)
  36. {
  37. if (currentMode == selectedMode)
  38. return;
  39. bool userConfirmed = SwitchModeConfirmationDialog.SwitchMode(
  40. currentMode == GuiMode.GluonMode, editorWindow);
  41. if (!userConfirmed)
  42. return;
  43. bool isGluonMode = selectedMode == GuiMode.GluonMode;
  44. workspaceWindow.UpdateWorkspaceForMode(isGluonMode);
  45. PendingChangesTreeHeaderState.SetMode(
  46. changesTreeView.multiColumnHeader.state,
  47. isGluonMode);
  48. }
  49. enum GuiMode
  50. {
  51. DeveloperMode,
  52. GluonMode
  53. }
  54. }
  55. }