There are 4 items in a Shop, each item’s availability is 1. Every time an item is being purchased, it’s gone from the shop forever, its cloned game object gets destroyed in the scene as well.
Say I purchased two (so two items are gone from the shop) and I saved the progress in the Shop Script. When I loaded the game after doing another purchase (1 left) or when I reloaded the game and loaded the progress (4 items in the shop). The inventory was updated, but the ShopUI didn’t get updated.
The item unique numbers and quantities are being saved. The picture below shows the soldItems (print(pair); ) in the saved file.
If I want to load the ShopUI correctly, should I compare the availabilities to the sold items to Destroy the cloned game objects?
How do I use foreach(…) to compare two lists (the availabilities to the sold items) in OnEnable like MainScreenSaveLoadUI? Or should I use this approach?
Should I compare the lists in the Shop or should I compare the lists in the ShopUI, and how do I compare them?
1)Shop Script: private Dictionary<InventoryItem, int> GetAvailabilities()
2)ShopUI Script: public void RefreshUI()