Save the state of a gameobject between scenes


I am trying to add currency to my game and that means that the player has to collect coins from the map that get stored and later on he can buy upgrades from the shop.

My problem is that when I restart the game or reload the scene the coins are still there. I want to make a script that remembers the state of the coin between scenes. I have been using player prefs to store some data, but I can’t figure out a way to save the state of the objects.

Use Object.DontDestroyOnLoad() in the script where you save all collected coins, the total amount, the player upgrades…