No Description
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.

DrawActionButton.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace Unity.PlasticSCM.Editor.UI
  4. {
  5. internal static class DrawActionButton
  6. {
  7. internal static bool For(string buttonText)
  8. {
  9. GUIContent buttonContent = new GUIContent(buttonText);
  10. return ForRegularButton(buttonContent);
  11. }
  12. internal static bool For(string buttonText, string buttonTooltip)
  13. {
  14. GUIContent buttonContent = new GUIContent(buttonText, buttonTooltip);
  15. return ForRegularButton(buttonContent);
  16. }
  17. internal static bool ForCommentSection(string buttonText)
  18. {
  19. GUIContent buttonContent = new GUIContent(buttonText);
  20. GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButton);
  21. buttonStyle.stretchWidth = false;
  22. float width = MeasureMaxWidth.ForTexts(buttonStyle, buttonText);
  23. Rect rt = GUILayoutUtility.GetRect(
  24. buttonContent,
  25. buttonStyle,
  26. GUILayout.MinWidth(width),
  27. GUILayout.MaxWidth(width));
  28. return GUI.Button(rt, buttonContent, buttonStyle);
  29. }
  30. static bool ForRegularButton(GUIContent buttonContent)
  31. {
  32. GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButton);
  33. buttonStyle.stretchWidth = false;
  34. Rect rt = GUILayoutUtility.GetRect(
  35. buttonContent,
  36. buttonStyle,
  37. GUILayout.MinWidth(UnityConstants.REGULAR_BUTTON_WIDTH));
  38. return GUI.Button(rt, buttonContent, buttonStyle);
  39. }
  40. }
  41. }