暫無描述
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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. mButtonGUIContent = new GUIContent(
  28. string.Empty, PlasticLocalization.Name.UnityVersionControl.GetString());
  29. }
  30. ~ToolbarButton()
  31. {
  32. PlasticPlugin.OnNotificationUpdated -= OnPlasticNotificationUpdated;
  33. }
  34. void OnPlasticNotificationUpdated()
  35. {
  36. Toolbar.RepaintToolbar();
  37. }
  38. public override void OnGUI(Rect rect)
  39. {
  40. Texture icon = PlasticPlugin.GetPluginStatusIcon();
  41. EditorGUIUtility.SetIconSize(new Vector2(16, 16));
  42. mButtonGUIContent.image = icon;
  43. if (GUI.Button(rect, mButtonGUIContent, "AppCommand"))
  44. {
  45. PlasticPlugin.OpenPlasticWindowDisablingOfflineModeIfNeeded();
  46. }
  47. EditorGUIUtility.SetIconSize(Vector2.zero);
  48. }
  49. GUIContent mButtonGUIContent;
  50. }
  51. }