Advertisement
KpoKec

Untitled

Dec 14th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 KB | None | 0 0
  1.         #region Mouse tools
  2.  
  3.         /// <summary>
  4.         ///     Invoke method after click (default: RMB)
  5.         /// </summary>
  6.         /// <param name="mouseButton">Mouse button</param>
  7.         /// <returns>Is clicked</returns>
  8.         public static bool CheckMouseClick(int mouseButton = 1)
  9.         {
  10.             var w = EditorWindow.mouseOverWindow;
  11.             if (w == null) return false;
  12.             var current = Event.current;
  13.             if (!current.isMouse || current.button != mouseButton) return false;
  14.             return GUILayoutUtility.GetLastRect().Contains(current.mousePosition);
  15.         }
  16.  
  17.         /// <summary>
  18.         ///     Invoke method if mouse over element
  19.         /// </summary>
  20.         /// <returns>Is over element</returns>
  21.         public static bool CheckMouseOver()
  22.         {
  23.             var w = EditorWindow.mouseOverWindow;
  24.             if (w == null) return false;
  25.             var current = Event.current;
  26.             return GUILayoutUtility.GetLastRect().Contains(current.mousePosition);
  27.         }
  28.  
  29.         public static bool CheckMouseButton(int button, bool ctrl = false, bool shift = false, bool alt = false)
  30.         {
  31.             var ev = Event.current;
  32.             return ev.button == button && ev.type == EventType.MouseDown && ev.control == ctrl && ev.shift == shift && ev.alt == alt;
  33.         }
  34.  
  35.         #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement