설명 없음
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.

HandleMenuItem.cs 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using PlasticGui;
  2. using System;
  3. using System.Reflection;
  4. using UnityEngine;
  5. namespace Unity.PlasticSCM.Editor.UI
  6. {
  7. internal static class HandleMenuItem
  8. {
  9. internal static void AddMenuItem(
  10. string name,
  11. int priority,
  12. Action execute,
  13. Func<bool> validate)
  14. {
  15. AddMenuItem(name, string.Empty, priority, execute, validate);
  16. }
  17. internal static void AddMenuItem(
  18. string name,
  19. string shortcut,
  20. int priority,
  21. Action execute,
  22. Func<bool> validate)
  23. {
  24. MethodInfo InternalAddMenuItem = MenuType.GetMethod(
  25. "AddMenuItem",
  26. BindingFlags.Static | BindingFlags.NonPublic);
  27. if (InternalAddMenuItem == null)
  28. {
  29. Debug.LogWarningFormat(
  30. PlasticLocalization.GetString(
  31. PlasticLocalization.Name.ErrorAddPlasticSCMMenuItem),
  32. name);
  33. return;
  34. }
  35. InternalAddMenuItem.Invoke(
  36. null, new object[] {
  37. name, shortcut, false,
  38. priority, execute, validate });
  39. }
  40. internal static void RemoveMenuItem(string name)
  41. {
  42. MethodInfo InternalRemoveMenuItem = MenuType.GetMethod(
  43. "RemoveMenuItem",
  44. BindingFlags.Static | BindingFlags.NonPublic);
  45. if (InternalRemoveMenuItem == null)
  46. {
  47. Debug.LogWarningFormat(
  48. PlasticLocalization.GetString(
  49. PlasticLocalization.Name.ErrorRemovePlasticSCMMenuItem),
  50. name);
  51. return;
  52. }
  53. InternalRemoveMenuItem.Invoke(
  54. null, new object[] { name });
  55. }
  56. internal static void UpdateAllMenus()
  57. {
  58. MethodInfo InternalUpdateAllMenus = EditorUtilityType.GetMethod(
  59. "Internal_UpdateAllMenus",
  60. BindingFlags.Static | BindingFlags.NonPublic);
  61. if (InternalUpdateAllMenus == null)
  62. {
  63. Debug.LogWarning(
  64. PlasticLocalization.GetString(
  65. PlasticLocalization.Name.ErrorUpdatePlasticSCMMenus));
  66. return;
  67. }
  68. InternalUpdateAllMenus.Invoke(null, null);
  69. }
  70. static readonly Type MenuType = typeof(UnityEditor.Menu);
  71. static readonly Type EditorUtilityType = typeof(UnityEditor.EditorUtility);
  72. }
  73. }