mergemilitary/Assets/Scripts/UIs/PanelBook.cs

55 lines
1.2 KiB
C#
Raw Normal View History

2022-05-23 13:39:59 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PanelBook : BasePanel
{
[SerializeField] Button mBtnClose;
[SerializeField] Transform mCtnTabs;
2022-09-09 14:35:49 +00:00
[SerializeField] List<CardList> mLists;
2022-05-23 13:39:59 +00:00
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;
}
2022-09-09 14:35:49 +00:00
mLists[0].IDPrefix = GameConfig.Instance.PlayerFar;
mLists[1].IDPrefix = GameConfig.Instance.PlayerNear;
2022-05-23 13:39:59 +00:00
}
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);
2022-09-09 14:35:49 +00:00
mLists[i].Show(i == mCurIndex);
if (i == mCurIndex)
{
mLists[i].LoadData();
}
2022-05-23 13:39:59 +00:00
}
}
}