IEvent.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using UnityEngine;
  2. using UnityEvent = UnityEngine.Event;
  3. namespace UnityEditor.U2D.Sprites
  4. {
  5. internal interface IEvent
  6. {
  7. EventType type { get; }
  8. string commandName { get; }
  9. bool control { get; }
  10. bool alt { get; }
  11. bool shift { get; }
  12. KeyCode keyCode { get; }
  13. Vector2 mousePosition { get; }
  14. int button { get; }
  15. EventModifiers modifiers { get; }
  16. EventType GetTypeForControl(int id);
  17. void Use();
  18. }
  19. internal class Event : IEvent
  20. {
  21. UnityEvent m_Event;
  22. public Event()
  23. {
  24. m_Event = UnityEvent.current;
  25. }
  26. public EventType type
  27. {
  28. get { return m_Event.type; }
  29. }
  30. public string commandName
  31. {
  32. get { return m_Event.commandName; }
  33. }
  34. public bool control
  35. {
  36. get { return m_Event.control; }
  37. }
  38. public bool alt
  39. {
  40. get { return m_Event.alt; }
  41. }
  42. public bool shift
  43. {
  44. get { return m_Event.shift; }
  45. }
  46. public KeyCode keyCode
  47. {
  48. get { return m_Event.keyCode; }
  49. }
  50. public Vector2 mousePosition
  51. {
  52. get { return m_Event.mousePosition; }
  53. }
  54. public int button
  55. {
  56. get { return m_Event.button; }
  57. }
  58. public void Use()
  59. {
  60. m_Event.Use();
  61. }
  62. public EventModifiers modifiers
  63. {
  64. get { return m_Event.modifiers; }
  65. }
  66. public EventType GetTypeForControl(int id)
  67. {
  68. return m_Event.GetTypeForControl(id);
  69. }
  70. }
  71. internal interface IEventSystem
  72. {
  73. IEvent current { get; }
  74. }
  75. internal class EventSystem : IEventSystem
  76. {
  77. public IEvent current
  78. {
  79. get { return new Event(); }
  80. }
  81. }
  82. }