暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

UnityEvents.cs 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using UnityEngine;
  2. using Codice.Utils;
  3. namespace Unity.PlasticSCM.Editor.UI
  4. {
  5. internal static class Keyboard
  6. {
  7. internal static bool IsShiftPressed(Event e)
  8. {
  9. if (e == null)
  10. return false;
  11. return e.type == EventType.KeyDown
  12. && e.shift;
  13. }
  14. internal static bool IsReturnOrEnterKeyPressed(Event e)
  15. {
  16. if (e == null)
  17. return false;
  18. return IsKeyPressed(e, KeyCode.Return) ||
  19. IsKeyPressed(e, KeyCode.KeypadEnter);
  20. }
  21. internal static bool IsKeyPressed(Event e, KeyCode keyCode)
  22. {
  23. if (e == null)
  24. return false;
  25. return e.type == EventType.KeyDown
  26. && e.keyCode == keyCode;
  27. }
  28. internal static bool IsControlOrCommandKeyPressed(Event e)
  29. {
  30. if (e == null)
  31. return false;
  32. if (PlatformIdentifier.IsMac())
  33. return e.type == EventType.KeyDown && e.command;
  34. return e.type == EventType.KeyDown && e.control;
  35. }
  36. }
  37. internal class Mouse
  38. {
  39. internal static bool IsLeftMouseButtonPressed(Event e)
  40. {
  41. if (e == null)
  42. return false;
  43. if (!e.isMouse)
  44. return false;
  45. return e.button == UnityConstants.LEFT_MOUSE_BUTTON
  46. && e.type == EventType.MouseDown;
  47. }
  48. internal static bool IsRightMouseButtonPressed(Event e)
  49. {
  50. if (e == null)
  51. return false;
  52. if (!e.isMouse)
  53. return false;
  54. return e.button == UnityConstants.RIGHT_MOUSE_BUTTON
  55. && e.type == EventType.MouseDown;
  56. }
  57. }
  58. }