How to change my crosshair on different tags?

Hi there I was wondering if anyone could help me out with the following code?
I’ve written some code that, when in first person view my raycast hits an object with the tab “inspectable”, a small click sound plays and when I click the object another sound plays and some UI comes up.
Now I was wondering how to implement some code that… 'When my raycast hits something with the tag “INTERACTable” the crosshair changes to another symbol (a hand for instance).

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class InspectRaycaster : MonoBehaviour
{
bool playAudio1;

[Header("SOUNDS")]
[SerializeField]
private AudioSource source;
[SerializeField]
private AudioClip Hitsound;
[SerializeField]
private AudioClip InfoSound;

[Header("CROSSHAIRS")]

public GameObject _DefaultCrosshair;
public GameObject _DefaultInspectIcon;

public GameObject _DefaultInteractIcon;

[Header("RAYCAST SETTINGS")]
[SerializeField] private int rayLenght = 10;
[SerializeField] private LayerMask LayerMaskInteract;
private ObjectController InspectableObject;

private bool isCrosshairActive;
private bool doOnce;
void start()
{
    InspectableObject = GameObject.Find("Objectcontroller").GetComponent<ObjectController>();
    Debug.Log("Found it");
}
private void Start()
{
    source.clip = Hitsound;

    _DefaultInspectIcon.SetActive(false);
    _DefaultInteractIcon.SetActive(false);
}
private void Update()
{

    RaycastHit hit;
    Vector3 fwd = transform.TransformDirection(Vector3.forward);

    if (Physics.Raycast(transform.position, fwd, out hit, rayLenght, LayerMaskInteract.value))
    {
        if (hit.collider.CompareTag("InspectObject"))

        {

            if (!doOnce)
            {

                InspectableObject = hit.collider.gameObject.GetComponent<ObjectController>();
                InspectableObject.ShowObjectName();
                CrosshairChange(true);
            }

            isCrosshairActive = true;
            doOnce = true;

            if (Input.GetMouseButtonDown(0))
            {
                InspectableObject.ShowExtraInfo();
                source.PlayOneShot(InfoSound);
            }

        }
    }
    else
    {
        if (isCrosshairActive)
        {

            InspectableObject.HideObjectName();
            CrosshairChange(false);
            doOnce = false;

        }
        if (hit.collider == null)
        {
            return;
        }
    }
}

void CrosshairChange(bool on)
{

    if (on && !doOnce)
    {
        _DefaultInspectIcon.SetActive(true);
        _DefaultCrosshair.SetActive(false);
        source.PlayOneShot(Hitsound);
        
    }
    
    else
    {
        _DefaultInspectIcon.SetActive(false);
        _DefaultCrosshair.SetActive(true);
    }
}

}

Hi @DieterLibotton !

The best way to do this, is to have a unique crosshair as an image in the UI. You can keep a reference in your code.

You can change the sprite that the image instead of Activate/Deactivate objects.

Something like this:

public class YourClass : MonoBehaviour 
{
        [SerializeField] private Image crosshairImage;
        [SerializeField] private Sprite crosshair_point;
        [SerializeField] private Sprite crosshair_hand;

        private void SomeCode()
        {
            ChangeCrosshairSprite(crosshair_hand);
        }
        
        private void SomeOtherCode()
        {
            ChangeCrosshairSprite(crosshair_point);
        }
        
        private void ChangeCrosshairSprite(Sprite newSprite)
        {
            crosshairImage.sprite = newSprite;
        }
}