File size: 1,987 Bytes
18a519f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | using UnityEditor;
using UnityEngine;
using PlasticGui;
using Unity.PlasticSCM.Editor;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.Cloud.Collaborate
{
[InitializeOnLoad]
internal static class ToolbarBootstrap
{
static ToolbarBootstrap()
{
CooldownWindowDelayer cooldownInitializeAction = new CooldownWindowDelayer(
ToolbarButton.InitializeIfNeeded, UnityConstants.PLUGIN_DELAYED_INITIALIZE_INTERVAL);
cooldownInitializeAction.Ping();
}
}
internal class ToolbarButton : SubToolbar
{
internal static void InitializeIfNeeded()
{
if (CollabPlugin.IsEnabled())
return;
ToolbarButton toolbar = new ToolbarButton { Width = 32f };
Toolbar.AddSubToolbar(toolbar);
}
ToolbarButton()
{
PlasticPlugin.OnNotificationUpdated += OnPlasticNotificationUpdated;
}
~ToolbarButton()
{
PlasticPlugin.OnNotificationUpdated -= OnPlasticNotificationUpdated;
}
void OnPlasticNotificationUpdated()
{
Toolbar.RepaintToolbar();
}
public override void OnGUI(Rect rect)
{
using (new EditorGUI.DisabledScope(EditorApplication.isPlaying))
{
Texture icon = PlasticPlugin.GetPluginStatusIcon();
EditorGUIUtility.SetIconSize(new Vector2(16, 16));
mButtonGUIContent.image = icon;
if (GUI.Button(rect, mButtonGUIContent, "AppCommand"))
{
PlasticPlugin.OpenPlasticWindowDisablingOfflineModeIfNeeded();
}
EditorGUIUtility.SetIconSize(Vector2.zero);
}
}
static GUIContent mButtonGUIContent = new GUIContent(
string.Empty, PlasticLocalization.GetString(
PlasticLocalization.Name.UnityVersionControl));
}
}
|