Firstborn/Library/PackageCache/com.unity.collab-proxy@2.0.3/Editor/PlasticSCM/UI/HandleMenuItem.cs
Schaken-Mods 9092858a58 updated to the latest editor
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
2023-05-07 17:43:11 -05:00

86 lines
2.5 KiB
C#

using PlasticGui;
using System;
using System.Reflection;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class HandleMenuItem
{
internal static void AddMenuItem(
string name,
int priority,
Action execute,
Func<bool> validate)
{
AddMenuItem(name, string.Empty, priority, execute, validate);
}
internal static void AddMenuItem(
string name,
string shortcut,
int priority,
Action execute,
Func<bool> validate)
{
MethodInfo InternalAddMenuItem = MenuType.GetMethod(
"AddMenuItem",
BindingFlags.Static | BindingFlags.NonPublic);
if (InternalAddMenuItem == null)
{
Debug.LogWarningFormat(
PlasticLocalization.GetString(
PlasticLocalization.Name.ErrorAddPlasticSCMMenuItem),
name);
return;
}
InternalAddMenuItem.Invoke(
null, new object[] {
name, shortcut, false,
priority, execute, validate });
}
internal static void RemoveMenuItem(string name)
{
MethodInfo InternalRemoveMenuItem = MenuType.GetMethod(
"RemoveMenuItem",
BindingFlags.Static | BindingFlags.NonPublic);
if (InternalRemoveMenuItem == null)
{
Debug.LogWarningFormat(
PlasticLocalization.GetString(
PlasticLocalization.Name.ErrorRemovePlasticSCMMenuItem),
name);
return;
}
InternalRemoveMenuItem.Invoke(
null, new object[] { name });
}
internal static void UpdateAllMenus()
{
MethodInfo InternalUpdateAllMenus = EditorUtilityType.GetMethod(
"Internal_UpdateAllMenus",
BindingFlags.Static | BindingFlags.NonPublic);
if (InternalUpdateAllMenus == null)
{
Debug.LogWarning(
PlasticLocalization.GetString(
PlasticLocalization.Name.ErrorUpdatePlasticSCMMenus));
return;
}
InternalUpdateAllMenus.Invoke(null, null);
}
static readonly Type MenuType = typeof(UnityEditor.Menu);
static readonly Type EditorUtilityType = typeof(UnityEditor.EditorUtility);
}
}