I am creating a shop system for my game and the problem that I am having right now is the state is not saving. If the Item is already bought I want the button to completely replaced by another button that has the function to use the bought item. But every time I restarted the game the button just goes back to the buy button.
All data in your code is part of the process, which is completely wiped of the RAM when the application is closed. When you want to store data in between application starts, you need to somehow write it into and load id from a persistent storage manually. The easiest way to do this is by using the PlayerPrefs class, which writes and loads date into/from the registry, in case of Windows, for example. If that’s not sufficient, you can always write and load files to/from Application.persistentDataPath. This is usually used to save and load serialized savegames.