I cannot change the sprite of a prefab clone

Hi everyone !
I am currently trying to change the sprite from the SpriteRenderer of an instantiated prefab to another after a collision.

I have attached a script to the prefab containing this :

public Sprite newSprite;

void OnTriggerEnter2D ( Collider2D col )
{
    GetComponent<SpriteRenderer>().sprite = newSprite;
}

My prefab has a BoxCollider2D and a RigibBody2D, and I am sure that I go through this code thanks to Debug.Log.
Furthermore, when I print the sprite before and after on the console, it looks like the sprite has changed.

However, in game nothing happens… I think it’s because I want to change the sprite of a clone and it’s an issue but I’m not sure.

I have searched for a lot a answers but nothing helped me.

Thanks in advance and have a good day !

Well I fixed the issues by disabling and activating the gameObject just after changing the sprite to force it to refresh the sprite. So i added this:

gameObject.SetActive(false);
gameObject.SetActive(true);

Really weird issue for a weird fix (thanks to chatGPT for giving me this fix !)

Here to second Ben’s answer. I had the same issue and forcing a refresh through SetActive worked for me.