60 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| 
 | |
| public class PanelShop : BasePanel
 | |
| {
 | |
|     [SerializeField] Button mBtnClose;
 | |
|     [SerializeField] Transform mCtnTabs;
 | |
|     [SerializeField] List<IListView> mLists;
 | |
| 
 | |
|     private List<TabButton> mTabs;
 | |
|     private int mCurIndex = -1;
 | |
| 
 | |
|     private void Awake()
 | |
|     {
 | |
|         UIUtils.BindBtn(mBtnClose, Close);
 | |
| 
 | |
|         mTabs = Utils.GetChildListFirstLayer<TabButton>(mCtnTabs);
 | |
| 
 | |
|         for (int i = 0; i < mTabs.Count; i++)
 | |
|         {
 | |
|             mTabs[i].DelClick = OnClickTab;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public override void OnOpen()
 | |
|     {
 | |
|         base.OnOpen();
 | |
| 
 | |
|         mTabs[0].gameObject.SetActive(GameConfig.Instance.UseDiamond);
 | |
|         mTabs[1].gameObject.SetActive(TKGSDKManager.Instance.GetConfigBool(TKGParamKey.UsePet));
 | |
|         mTabs[2].gameObject.SetActive(TKGSDKManager.Instance.GetConfigBool(TKGParamKey.UseBoard));
 | |
| 
 | |
|         if (mCurIndex < 0)
 | |
|         {
 | |
|             int tInitIndex = 0;
 | |
|             if (!GameConfig.Instance.UseDiamond)
 | |
|             {
 | |
|                 tInitIndex = TKGSDKManager.Instance.GetConfigBool(TKGParamKey.UsePet) ? 1 : 2;
 | |
|             }
 | |
|             OnClickTab(tInitIndex);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void OnClickTab(int pIndex)
 | |
|     {
 | |
|         mCurIndex = pIndex;
 | |
| 
 | |
|         for (int i = 0; i < mTabs.Count; i++)
 | |
|         {
 | |
|             mTabs[i].SetOn(i == mCurIndex);
 | |
|             mLists[i].Show(i == mCurIndex);
 | |
|             if (i == mCurIndex)
 | |
|             {
 | |
|                 mLists[i].LoadData();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| } |