92 lines
3.4 KiB
C#
92 lines
3.4 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class TabCardBase : CardBase
|
|
{
|
|
public eTabType m_TabType;
|
|
public string BGImage_on, BGImage_off;
|
|
public GameObject[] gos_onoff;
|
|
public GameObject[] gos_off; // 탭이 off될 때 같이 off되는 오브젝트들
|
|
public Button m_btn;
|
|
public Image[] images; // 0 bg, 1 이미지
|
|
[SerializeField] Color TextCol_on = new Color(1f, 1f, 1f, 1f);
|
|
[SerializeField] Color TextCol_off = new Color(1f, 1f, 1f, 1f);
|
|
public TextMeshProUGUI[] texts; // 0 탭 이름
|
|
|
|
TabUIData m_Data;
|
|
|
|
public override void Set<T>(T _base)
|
|
{
|
|
m_btn.onClick.RemoveAllListeners();
|
|
m_btn.onClick.AddListener(OnClick_Tab);
|
|
base.Set(_base);
|
|
m_Data = _base as TabUIData;
|
|
if (texts.Length > 0)
|
|
{
|
|
for (int i = 0; i < texts.Length; i++)
|
|
{
|
|
texts[i].text = string.IsNullOrEmpty(m_Data.btnName) ? table_localtext.Ins.Get_Text(m_Data.n_btnName) : m_Data.btnName;
|
|
texts[i].color = TextCol_off;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Set_CardType(eUICardType _type)
|
|
{
|
|
if (_type == eUICardType.UI)
|
|
{
|
|
if (m_TabType == eTabType.BGColorChange)
|
|
images[0].color = m_Data.color_bg_on;
|
|
else if (m_TabType == eTabType.BGImageChange)
|
|
{
|
|
images[0].color = new Color(images[0].color.r, images[0].color.g, images[0].color.b, 1f);
|
|
images[0].sprite = UIAtlasMgr.Ins.Get_Sprite(BGImage_on);
|
|
}
|
|
else if (m_TabType == eTabType.OnOff)
|
|
DSUtil.InActivateGameObjects(gos_onoff, 0);
|
|
|
|
if (images.Length > 1) images[1].sprite = UIAtlasMgr.Ins.Get_Sprite(m_Data.btnImg_on);
|
|
if (texts.Length > 0) texts[0].color = TextCol_on;
|
|
if (!DSUtil.CheckNull(gos_off))
|
|
{
|
|
for (int i = 0; i < gos_off.Length; i++)
|
|
gos_off[i].SetActive(true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (m_TabType == eTabType.BGColorChange)
|
|
images[0].color = m_Data.color_bg_off;
|
|
else if (m_TabType == eTabType.OnOff)
|
|
DSUtil.InActivateGameObjects(gos_onoff, 1);
|
|
else if (m_TabType == eTabType.BGImageChange)
|
|
{
|
|
if (BGImage_off.Equals("nothing"))
|
|
images[0].color = new Color(images[0].color.r, images[0].color.g, images[0].color.b, 0f);
|
|
else
|
|
{
|
|
images[0].color = new Color(images[0].color.r, images[0].color.g, images[0].color.b, 1f);
|
|
images[0].sprite = UIAtlasMgr.Ins.Get_Sprite(BGImage_off);
|
|
}
|
|
}
|
|
|
|
if (images.Length > 1) images[1].sprite = UIAtlasMgr.Ins.Get_Sprite(m_Data.btnImg_off);
|
|
if (texts.Length > 0) texts[0].color = TextCol_off;
|
|
if (!DSUtil.CheckNull(gos_off))
|
|
{
|
|
for (int i = 0; i < gos_off.Length; i++)
|
|
gos_off[i].SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override int Get_IntData() { return m_Data.m_Index; }
|
|
|
|
public void OnClick_Tab() { if (m_Data.CanTouch) OnClickTab_Force(); }
|
|
public void OnClickTab_Force()
|
|
{
|
|
m_Data.onTabAction?.Invoke(m_Data.m_Index); // 먼저 실행
|
|
m_Data.onClick?.Invoke(); // 다음 실행
|
|
}
|
|
} |