How do I correctly get the component of a instatiated prefab?

I’m trying to fade out an instantiated prefabs color. Here’s what I have

public class ImageSpawner : MonoBehaviour
{
    public Transform spawnTransformPos;
    public GameObject spritePrefab;
    public Sprite sprite;
    public bool isSpriteSpawned;


    void Start()
    {
        isSpriteSpawned = false;
        if (spawnTransformPos == null)
        {
            spawnTransformPos = transform;
        }
    }

    void Update()
    {
        if (Input.GetKeyDown("f"))
        {
            SpawnImage();
        }
    }

    public void SpawnImage()
    {
        if (isSpriteSpawned == false)
        {
            isSpriteSpawned = true;
            GameObject newSprite = (GameObject)Instantiate(spritePrefab, spawnTransformPos);
            Color color = newSprite.GetComponent<SpriteRenderer>().material.color;
            Debug.Log("Image spawned");

            StartCoroutine(FadeSprite(color));
        }
    }
    
    IEnumerator FadeSprite(Color _color)
    {
        while (_color.a > 0.0f)
        {
            _color.a -= 1.0f * Time.deltaTime;
            yield return null;
        }
    }
}

Before cleaning it up a bit to paste here I had it verifying that _color.a was being reduced over time, however this _color was not attached to the Color of the instantiated prefab. Nothing would happen to the instance. What do I need to do to get the Color of the prefab and modify it?

Color is a value type. When you call Color color = newSprite.GetComponent<SpriteRenderer>().material.color;, you actually create a complete new color instance of the struct with the same value as the material’s one. Thus, modifying the copy won’t change the original one.

 IEnumerator FadeSprite(Material _material)
 {
     Color color = _material.color;
     while (color.a > 0.0f)
     {
         color.a -= 1.0f * Time.deltaTime;
         _material.color = color;
         yield return null;
     }
 }