using ShiroginSDK.Runtime.Modules.IAP.Enums; using ShiroginSDK.Runtime.Modules.IAP.Scripts.Definitions; using TMPro; using UnityEngine; using UnityEngine.UI; namespace ShiroginSDK.Runtime.Modules.IAP.Scripts.UI.Items { /// /// Displays a single reward entry (icon + text) inside a reward grid. /// Used by Bundles, Chests, and Rewarded items. /// public class UIRewardEntry : MonoBehaviour { [Header("🎁 UI References")] [SerializeField] private Image iconImage; [SerializeField] private TextMeshProUGUI amountText; /// /// Initializes the reward UI with given data. /// public void Setup(RewardDefinition reward) { if (reward == null) { Debug.LogWarning("[UIRewardEntry] Tried to setup with null reward!"); return; } // 🖼️ Icon if (iconImage) { iconImage.sprite = reward.icon; iconImage.enabled = reward.icon != null; } // 💬 Text if (amountText) switch (reward.rewardType) { case RewardType.RemoveAds: amountText.text = "No Ads"; break; case RewardType.Character: amountText.text = $"#{reward.characterId}"; break; case RewardType.Gold: case RewardType.Ticket: case RewardType.Gems: amountText.text = $"+{reward.amount} {reward.rewardType}"; break; default: amountText.text = reward.amount > 0 ? $"+{reward.amount} {reward.rewardType}" : reward.rewardType.ToString(); break; } } } }