How do I change my crosshair/cursor when I look at an object

Hi There. I want my crosshair to change when I look at something. In this case a shelf. The script I have dons’t seem to work. What do I have to do?

var CrosshairTexture : Texture2D;
 
var UseTexture : Texture2D;
 
var NormalTexture : Texture2D;
     
var ShowCrosshair : boolean = true;
 
var CanChange : boolean = false;
         
function Start()
{      
        Screen.lockCursor = true;
}
         
function OnGUI()
{
        if(ShowCrosshair == true)
        {
        GUI.Label(Rect((Screen.width - CrosshairTexture.width) /2, (Screen.height -
                        CrosshairTexture.height) /2, CrosshairTexture.width, CrosshairTexture.height), CrosshairTexture);
        }
 
}
 
 
function OnTriggerEnter(other : Collider)
{
        if(other.gameObject.tag == "Drag")
        {
                CanChange = false;
       
                CrosshairTexture = UseTexture;
       
        }
 
}
 
function OnTriggerExit(other : Collider)
{
        if(other.gameObject.tag == "Drag")
        {
                CanChange = true;
       
                CrosshairTexture = NormalTexture;
               
               
        }
 
}
 
function TextureChange(){
 
if(!CanChange)
{
 
CrosshairTexture = UseTexture;
 
CanChange = true;
 
}
 
}
 
function BackToNormal(){
 
if(CanChange)
{
 
CanChange = false;
 
CrosshairTexture = NormalTexture;
}
 
}

I think your case Raycast is much usefuller.
Try this:

var objectname : string = tag of the Bookshelfobject

    write here the vars for your Textures
    
    function OnGUI()
    {
    var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    var hit = RaycastHit;
        if (Physics.Raycast (ray,hit, here the lenght of the Raycast maby 100)) {
            if(hit.collider.tag == objectname)
    {
          
      GUI.Label(Rect((Screen.width - UseTexture.width) /2, (Screen.height -
                            UseTexture.height) /2, UseTexture.width, UseTexture.height), UseTexture);
    }
    else
GUI.Label(Rect((Screen.width - UseTexture.width) /2, (Screen.height -UseTexture.height) /2, UseTexture.width, UseTexture.height), UseTexture);
    }
else
GUI.Label(Rect((Screen.width - UseTexture.width) /2, (Screen.height -UseTexture.height) /2, UseTexture.width, UseTexture.height), UseTexture);
}

Contact me when you have Errors with the script.