55 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| 
 | |
| public class PanelBook : BasePanel
 | |
| {
 | |
|     [SerializeField] Button mBtnClose;
 | |
|     [SerializeField] Transform mCtnTabs;
 | |
|     [SerializeField] List<CardList> 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;
 | |
|         }
 | |
| 
 | |
|         mLists[0].IDPrefix = GameConfig.Instance.PlayerFar;
 | |
|         mLists[1].IDPrefix = GameConfig.Instance.PlayerNear;
 | |
|     }
 | |
| 
 | |
|     public override void OnOpen()
 | |
|     {
 | |
|         base.OnOpen();
 | |
| 
 | |
|         if (mCurIndex < 0)
 | |
|         {
 | |
|             OnClickTab(0);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     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();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| } |