DrawUserIcon.cs 987 B

1234567891011121314151617181920212223242526272829303132333435
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace Unity.PlasticSCM.Editor.UI
  4. {
  5. internal static class DrawUserIcon
  6. {
  7. static internal void ForPendeingChangesTab(string commentText)
  8. {
  9. Rect rect = BuildUserIconAreaRect(commentText, 35f);
  10. GUI.DrawTexture(rect, GetIconTexture());
  11. }
  12. static Rect BuildUserIconAreaRect(string commentText, float sizeOfImage)
  13. {
  14. GUIStyle commentTextAreaStyle = UnityStyles.PendingChangesTab.CommentTextArea;
  15. Rect result = GUILayoutUtility.GetRect(sizeOfImage, sizeOfImage); // Needs to be a square
  16. result.x = commentTextAreaStyle.margin.left;
  17. return result;
  18. }
  19. static Texture2D GetIconTexture()
  20. {
  21. if (sUserIconImage == null)
  22. sUserIconImage = Images.GetImage(Images.Name.IconEmptyGravatar);
  23. return sUserIconImage;
  24. }
  25. static Texture2D sUserIconImage;
  26. }
  27. }