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.

ToolbarButton.cs 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using UnityEditor;
  2. using UnityEngine;
  3. using PlasticGui;
  4. using Unity.PlasticSCM.Editor;
  5. namespace Unity.Cloud.Collaborate
  6. {
  7. [InitializeOnLoad]
  8. internal static class ToolbarBootstrap
  9. {
  10. static ToolbarBootstrap()
  11. {
  12. ToolbarButton.InitializeIfNeeded();
  13. }
  14. }
  15. internal class ToolbarButton : SubToolbar
  16. {
  17. internal static void InitializeIfNeeded()
  18. {
  19. if (CollabPlugin.IsEnabled())
  20. return;
  21. ToolbarButton toolbar = new ToolbarButton { Width = 32f };
  22. Toolbar.AddSubToolbar(toolbar);
  23. }
  24. ToolbarButton()
  25. {
  26. PlasticPlugin.OnNotificationUpdated += OnPlasticNotificationUpdated;
  27. }
  28. ~ToolbarButton()
  29. {
  30. PlasticPlugin.OnNotificationUpdated -= OnPlasticNotificationUpdated;
  31. }
  32. void OnPlasticNotificationUpdated()
  33. {
  34. Toolbar.RepaintToolbar();
  35. }
  36. public override void OnGUI(Rect rect)
  37. {
  38. Texture icon = PlasticPlugin.GetPluginStatusIcon();
  39. EditorGUIUtility.SetIconSize(new Vector2(16, 16));
  40. mButtonGUIContent.image = icon;
  41. if (GUI.Button(rect, mButtonGUIContent, "AppCommand"))
  42. {
  43. PlasticPlugin.OpenPlasticWindowDisablingOfflineModeIfNeeded();
  44. }
  45. EditorGUIUtility.SetIconSize(Vector2.zero);
  46. }
  47. static GUIContent mButtonGUIContent = new GUIContent(
  48. string.Empty, PlasticLocalization.GetString(
  49. PlasticLocalization.Name.UnityVersionControl));
  50. }
  51. }