I have a script that defines a set of public variables, some of them contain GameObjects that represent Prefabs, some of these Prefabs have attached scripts that define public variables of their own. The problem I have is that when some script modifies a public variable, the Prefab to which it belongs is updated permanently, that is, the original values are never restored when the game ends, so when I run the game for a second time I get a unwanted behaviors. It becomes worst when a script modifies a SpriteRenderer, because when this happens, the Prefab is updated with a Sprite that exists only in memory, which causes it to become broken in such a way that it is impossible to make the game run for a second time without having to manually restore the Prefab to its original state.
Is there a way I can modify public variables exclusively in memory, so when the game ends all changes are lost?