using TMPro; using UnityEngine; using UnityEngine.UI; namespace BulletHellTemplate { /// /// Represents an entry in the IAP shop for purchasing an item. /// Displays the item information and allows the user to initiate a purchase. /// public class ShopIAPEntry : MonoBehaviour { [Header("UI Elements")] [Tooltip("Text for displaying the item's name.")] public TextMeshProUGUI itemName; // Text for the item name [Tooltip("Text for displaying the price of the item.")] public TextMeshProUGUI price; // Text for the item price public TextMeshProUGUI description; [Tooltip("Image for displaying the item's icon.")] public Image itemIcon; // Image for the item icon private IAPItem iapItem; // Reference to the IAP item /// /// Sets the UI elements with the information of the given IAP item. /// /// The IAP item to display in this entry. public void SetItemInfo(IAPItem iapItem , string _itemName, string item_description) { this.iapItem = iapItem; itemName.text = _itemName; description.text = item_description; price.text = "$" + iapItem.priceInUSD.ToString("F2"); // Display price in USD with two decimal places itemIcon.sprite = iapItem.itemIcon; } /// /// Opens the purchase confirmation popup for the selected item. /// public void OpenConfirmBuyPopup() { UIShopIAP.Singleton.OpenBuyPopup(iapItem); } } }