Collision between GUI Texture and Object


I’m using this code to get a GUI Texture to follow my cursor:

var player : Texture2D;

function OnGUI() {
var mousePos : Vector3 = Input.mousePosition;
GUI.Label(Rect(mousePos.x, Screen.height-mousePos.y, player.width, player.height), player);

Now how could I detect collisions between that GUI texture, and an object that is in the scene? (I can’t use OnMouseOver because the GUI texture that is being projected is much larger than my actual cursor)

Thanks in advance. :slight_smile:

You can use the GUITexture.HitTest() method.