65 lines
No EOL
2 KiB
C#
65 lines
No EOL
2 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Displays a single reward entry (icon + text) inside a reward grid.
|
|
/// Used by Bundles, Chests, and Rewarded items.
|
|
/// </summary>
|
|
public class UIRewardEntry : MonoBehaviour
|
|
{
|
|
[Header("🎁 UI References")] [SerializeField]
|
|
private Image iconImage;
|
|
|
|
[SerializeField]
|
|
private TextMeshProUGUI amountText;
|
|
|
|
/// <summary>
|
|
/// Initializes the reward UI with given data.
|
|
/// </summary>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
} |