public void PurchaseProduct(Transform product) { if (product.CompareTag("Product")) { StockItem stockItem = product.GetComponent <StockItem>(); if (stockItem) { if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != "MainMenu") { gameManager.AddScore(mapManager.GetStockTypePrice(stockItem.GetStockType())); } if (gameInfo) { gameInfo.AddProductSold(stockItem.GetStockType()); } PushPriceToaster(mapManager.GetStockTypePrice(stockItem.GetStockType())); // Delete sold product product.SetParent(null); Destroy(product.gameObject); } else { Debug.LogError("Product is missing the StockItem component!", stockItem); } } }