Make changes to Sprites/Default Material and not saving this change in prefabs.

I have a background which has a sprite renderer with Sprites /Default Material on it , and i change the materials color in the update function and after the game ends and i press playagain the material already has that color applied to it , i want that color to be reset back to the one which as at the start.

Here is the little code snippet .

I have simple Material and i changed it’s color in default . like

Background.GetComponent ().material.color = Color.Lerp (new Color (0.20f, 0.19f, 0.19f, 1), new Color (0.78f, 0.11f, 0.11f, 1), time / 4);

and i also have game setup function which i call in the start and at replay . that function contains the following code .

Background.GetComponent ().material.color = Color.black;

But the the color doesn’t change back to normal after the first play , i mean the line doesn’t work when i press replay , i have debugged the code , the code at this breakpoint is reachable but is not having any affect , really confused.

At a guess, you’re modifying sharedMaterial.color, which will modify the asset on disk and persist even after playmode stops.
To modify just the instance of the material attached to the object during runtime, change material.color instead.