50 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| 
 | |
| public class DiamondCell : ListCell
 | |
| {
 | |
|     public Action<int> DelPurchase;
 | |
| 
 | |
|     public Vector3 IconPos => mImgIcon.transform.position;
 | |
| 
 | |
|     [SerializeField] Text mTxtNum;
 | |
|     [SerializeField] Image mImgIcon;
 | |
|     [SerializeField] Text mTxtPrice;
 | |
|     [SerializeField] Button mBtnPurchase;
 | |
| 
 | |
|     private DataIAP mData;
 | |
| 
 | |
|     private void Awake()
 | |
|     {
 | |
|         UIUtils.BindBtn(mBtnPurchase, OnClickPuchase);
 | |
|     }
 | |
| 
 | |
|     public void ConfigCell(DataIAP pData)
 | |
|     {
 | |
|         mData = pData;
 | |
| 
 | |
|         mTxtNum.text = mData.DiamondNum.ToString();
 | |
|         mImgIcon.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetDiamondIcon(mData.Icon));
 | |
|         mImgIcon.SetNativeSize();
 | |
| 
 | |
|         if (TKGSDKManager.Instance.IsIAPEnabled)
 | |
|         {
 | |
| #if UNITY_EDITOR
 | |
|             mTxtPrice.text = mData.Price;
 | |
| #else
 | |
|             mTxtPrice.text = IAPTool.Instance.GetPriceByID(pData.ProductID);
 | |
| #endif
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             mTxtPrice.text = mData.Price;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void OnClickPuchase()
 | |
|     {
 | |
|         DelPurchase?.Invoke(mIndex);
 | |
|     }
 | |
| } |