// Fills the main part of the shop screen with inventory for purchase void PopulateGrid() { // Load a shop panel template GameObject newPanel; GameObject prefabPanel = Resources.Load <GameObject>(@"MenuPrefabs\prefabShopPanel"); // Retrieve the Inventory of the Party Inventory partyStash = BattleLoader.Party.Inventory; // Shop.Stock was populated during file load or during Initializing foreach (InvItem item in Shop.Stock.Contents) { // Create instances of the shopPanel, naming Content object as its parent newPanel = GameObject.Instantiate(prefabPanel, gridContent.transform); ShopPanel shopPanel = newPanel.GetComponent <ShopPanel>(); // Retrieve the number of identical items from the partyStash int held = 0; if (partyStash.ContainsItem(item.Name)) { held = partyStash.Contents[partyStash.IndexOfItem(item.Name)].Quantity; } // Set up the shop Panel with the InvItem from Shop.Stock shopPanel.SetPanel(item, held); } }