Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1.     // Update is called once per frame
  2.     void OnGUI ()
  3.     {
  4.         //gui version
  5.         var rect = new Rect (0, 0, Screen.width*0.2f, Screen.height*0.2f);
  6.         if (GUI.Button(rect, "left"))
  7.         {
  8.  
  9.         }
  10.  
  11.         //layout version (worse)
  12.         if (GUILayout.Button ("crud", GUILayout.Width(200), GUILayout.ExpandHeight(true)))
  13.         {
  14.         }
  15.         var rect = GUILayoutUtility.GetLastRect();
  16.  
  17.  
  18.         //detect mouse in the screen rect of the button
  19.         if (/*Event.current.type.Equals(EventType.MouseUp) && */rect.Contains(Event.current.mousePosition))
  20.         {
  21.             Debug.Log ("mouse");
  22.         }
  23.  
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement