using UnityEngine; using UnityEngine.UI; using TMPro; public class bagItemPreviewPrefab : MonoBehaviour { public Image btm_img; public Image profileImage; public Text itemName; public Text itemToUsing; public Text itemDescription; public TextMeshProUGUI itemAmount; public void Bind(Color backgroundColor, Sprite backgroundSprite, Sprite icon, string displayName, string usage, string description, string amountText) { if (btm_img != null) { btm_img.sprite = backgroundSprite; btm_img.color = backgroundSprite != null ? Color.white : backgroundColor; } if (profileImage != null) { profileImage.sprite = icon; profileImage.enabled = icon != null; profileImage.color = Color.white; } if (itemName != null) { itemName.text = displayName ?? string.Empty; } if (itemToUsing != null) { itemToUsing.text = usage ?? string.Empty; } if (itemDescription != null) { itemDescription.text = description ?? string.Empty; } if (itemAmount != null) { itemAmount.text = amountText ?? string.Empty; } } }