Files
Test/Library/PackageCache/com.unity.collab-proxy@4628d2ba6ea4/Editor/SwitchUVCSPlugin.cs
T
2026-11-01 23:39:55 +02:00

60 lines
1.5 KiB
C#

using Unity.PlasticSCM.Editor.Inspector.Properties;
using Unity.PlasticSCM.Editor.Settings;
using Unity.PlasticSCM.Editor.UI;
using UnityEditor;
namespace Unity.PlasticSCM.Editor
{
internal static class SwitchUVCSPlugin
{
internal static UVCSWindow On(UVCSPlugin uvcsPlugin)
{
UVCSPluginIsEnabledPreference.Enable();
uvcsPlugin.Enable();
UVCSWindow window = ShowWindow.UVCS();
return window;
}
internal static UVCSWindow OnIfNeeded(UVCSPlugin uvcsPlugin)
{
if (!UVCSPluginIsEnabledPreference.IsEnabled())
{
UVCSWindow result = On(uvcsPlugin);
ReloadSettings();
return result;
}
return ShowWindow.UVCS();
}
internal static void Off(UVCSPlugin uvcsPlugin)
{
UVCSPluginIsEnabledPreference.Disable();
CloseWindowIfOpened.UVCS();
CloseWindowIfOpened.BranchExplorer();
CloseWindowIfOpened.Diff();
CleanSelectionIfNeeded();
uvcsPlugin.Shutdown();
}
static void ReloadSettings()
{
UVCSProjectSettingsProvider.GetIfActive()?.ReloadSettings();
}
static void CleanSelectionIfNeeded()
{
if (!(Selection.activeObject is SelectedRepObjectInfoData))
return;
Selection.activeObject = null;
}
}
}