void HandleProduct(ExampleProduct product, XmlElement item, int productId) { var image = item.GetElementByInternalId <Image>("productImage"); if (product.Image != null) { image.sprite = product.Image; } image.color = Color.white; var button = item.GetElementByInternalId <Button>("productBuyButton"); button.GetComponentInChildren <Text>().text = String.Format("${0}", product.Price); button.onClick.AddListener(new UnityEngine.Events.UnityAction(() => { PurchaseButtonClicked(productId); })); var productQuantity = item.GetElementByInternalId <Text>("productQuantity"); productQuantity.text = String.Format("x{0}", product.Quantity); if (product.IsBestDeal) { var ribbon = item.GetElementByInternalId <Image>("productBestDeal"); ribbon.gameObject.SetActive(true); } }
public void AddCurrency(ExampleProduct productPurchased) { var currency = CurrencyQuantities.First(c => c.Name == productPurchased.Name); currency.Quantity += productPurchased.Quantity; UpdateDisplay(); }
public void Show(ExampleProduct product, Action <ExampleProduct> callback = null) { xmlLayout.Show(); this.product = product; this.callback = callback; // Because this dialog may not have been active yet at this point, // we need to wait a frame to make sure that the XmlLayout has finished setting up StartCoroutine(DelayedShow()); }
public void PurchaseConfirmed(ExampleProduct product) { CurrencyOverlay.AddCurrency(product); }