But when I run this code, the color is always set to white. but there seems to be a change in the sprite- Default material. Is this material different from the material used to get the color (spriteRenderer.material.color) The image below shows where the color change shows in the inspector
That’s why your sprite’s material name has (Instance) at the end.
on other hand, sprite.color and sprite.material.color are not the same thing. sprite.color is the color of the sprite mesh, which gets later tinted by the color of the material.
Either set and get the color of the material, or set and get the color of the sprite mesh. Right now you’re copying the material, assigning a color to that material, then getting the color of the sprite (which is still white because you haven’t changed it anywhere)