custom mouse changing when hovering over objects

hi i have a custom mouse for my unity game but i want it to when hovering over something to change to a different mouse cursor here is my code for the mouse cursor so far:

using UnityEngine;

using System.Collections;

public class CursorIcon : MonoBehaviour

{

public static int guiDepth = 0;

public Texture2D cursorImage;

private int cursorWidth = 32;

private int cursorHeight = 32;

void Awake() {

    DontDestroyOnLoad(this);    

}

void Start()

{

    Screen.showCursor = false;

}

void OnGUI()

{

    GUI.depth = guiDepth;

    GUI.DrawTexture(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, cursorWidth, cursorHeight), cursorImage);

}

void Update() {

}

}

any help will be appreciated thank you.

You can use the Rect.Contains method to detect if the mouse is over a specific area of the screen/GUI and react accordingly...

Something like:

var btnTexture : Texture;
var btnCursor1 : Texture;
var btnCursor2 : Texture;
var rectForButton: Rect = Rect (10, 10, 150, 150);

if (rectForButton.Contains(Input.mousePosition))
    cursorImage = btnCursor2;
else
    cursorImage = btnCursor2;

GUI.DrawTexture(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, cursorWidth, cursorHeight), cursorImage);