I have a button on the scene (A GUI element). I hover mouse over this button. How could I get the X and Y coordinates of that button? I mean, when I hover my mouse over a button - some Event should trigger. I would like to get some data from that event (like coordinates). But I just don't know from where to get this data. Thank you for your help.
GUI Elements coord are in Screen Coord, so what you seems to want is this : Code (csharp): using UnityEngine; public class SimpleButton : MonoBehaviour { Rect myButtonRect = new Rect(20,20,100,50) ; void OnGUI() { if(Event.current.type == EventType.repaint myButtonRect.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y))) { //Do on rollOver } if(GUI.Button(myButtonRect, "myButton")) { //Do on click } } }