using System.Collections; using System.Collections.Generic; using TMPro; using UniRx; using UnityEngine; using UnityEngine.UI; namespace TON { // View public class ShopItemUI : MonoBehaviour { [SerializeField] private Image image; [SerializeField] private TextMeshProUGUI title; [SerializeField] private TextMeshProUGUI txtPrice; [SerializeField] private Button buyButton; public void Bind(ShopItemPresenter presenter) { presenter.Price.Subscribe(text => txtPrice.text = text.ToString()).AddTo(this); presenter.PotionType.CombineLatest(presenter.Quantity, (type, quantity)=> $"{type} 포션 {quantity}개") .Subscribe(text => title.text = text) .AddTo(this); presenter.BuyCommand.BindTo(buyButton).AddTo(this); } [ContextMenu("Bind")] public void BindReference() { image = transform.Find("ItemLayout/ItemImage").GetComponent(); title = transform.Find("ItemLayout/Text (TMP)").GetComponent(); txtPrice = transform.Find("ItemLayout/Button/Text (TMP)").GetComponent(); buyButton = transform.Find("ItemLayout/Button").GetComponent