127 lines
4.6 KiB
C#
127 lines
4.6 KiB
C#
|
|
using TMPro;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
public class TabCardBase : CardBase
|
||
|
|
{
|
||
|
|
public eTabType m_TabType;
|
||
|
|
|
||
|
|
[Header("On 일 때 활성화 되는 오브젝트")]
|
||
|
|
public GameObject go_TabOnOff_on;
|
||
|
|
[Header("Off 일 때 활성화 되는 오브젝트")]
|
||
|
|
public GameObject go_TabOnOff_off;
|
||
|
|
[Header("on/off 시 Tab bg 색깔 변경")]
|
||
|
|
public Color color_bg_on = new Color(1f, 1f, 1f, 1f);
|
||
|
|
public Color color_bg_off = new Color(0.8f, 0.8f, 0.8f, 1f);
|
||
|
|
[Header("on/off 시 Tab BG 이미지 변경 Sprite 이름")]
|
||
|
|
public string Tab_BG_Img_on;
|
||
|
|
public string Tab_BG_Img_off;
|
||
|
|
[Header("on/off 시 Tab bg 색깔 변경")]
|
||
|
|
public Color color_img_on = new Color(1f, 1f, 1f, 1f);
|
||
|
|
public Color color_img_off = new Color(1f, 1f, 1f, 1f);
|
||
|
|
|
||
|
|
[Header("------------------------------------------")]
|
||
|
|
|
||
|
|
[Header("on/off 시 Tab 버튼 텍스트 색깔 변경")]
|
||
|
|
public Color color_text_on = new Color(1f, 1f, 1f, 1f);
|
||
|
|
public Color color_text_off = new Color(1f, 1f, 1f, 1f);
|
||
|
|
[Header("on/off 시 Tab 이미지 변경 Sprite 이름")]
|
||
|
|
public string Tab_Img_on;
|
||
|
|
public string Tab_Img_off;
|
||
|
|
[Header("Tab off 시 같이 off되는 오브젝트들")]
|
||
|
|
public GameObject[] gos_off;
|
||
|
|
|
||
|
|
[Header("------------------------------------------")]
|
||
|
|
public Button m_btn;
|
||
|
|
public Image[] images; // 0 bg, 1 이미지
|
||
|
|
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;
|
||
|
|
for (int i = 0; i < texts.Length; i++)
|
||
|
|
{
|
||
|
|
texts[i].text = m_Data.btnName;
|
||
|
|
texts[i].color = color_text_off;
|
||
|
|
if (m_Data.n_btnName > 0) texts[i].text = table_localtext.Ins.Get_Text(m_Data.n_btnName);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void Set_CardType(eUICardType _type)
|
||
|
|
{
|
||
|
|
if (_type == eUICardType.UI)
|
||
|
|
{
|
||
|
|
if (m_TabType == eTabType.BGColorChange)
|
||
|
|
images[0].color = 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(Tab_BG_Img_on);
|
||
|
|
}
|
||
|
|
else if (m_TabType == eTabType.OnOff)
|
||
|
|
{
|
||
|
|
go_TabOnOff_on.SetActive(true);
|
||
|
|
go_TabOnOff_off.SetActive(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (images.Length > 1 && images[1] != null)
|
||
|
|
{
|
||
|
|
images[1].enabled = m_Data.SetImg;
|
||
|
|
images[1].sprite = UIAtlasMgr.Ins.Get_Sprite(m_Data.imgName_On);
|
||
|
|
images[1].color = color_img_on;
|
||
|
|
}
|
||
|
|
if (texts.Length > 0) texts[0].color = color_text_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 = color_bg_off;
|
||
|
|
else if (m_TabType == eTabType.OnOff)
|
||
|
|
{
|
||
|
|
go_TabOnOff_on.SetActive(false);
|
||
|
|
go_TabOnOff_off.SetActive(true);
|
||
|
|
}
|
||
|
|
else if (m_TabType == eTabType.BGImageChange)
|
||
|
|
{
|
||
|
|
if (Tab_BG_Img_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(Tab_BG_Img_off);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (images.Length > 1)
|
||
|
|
{
|
||
|
|
images[1].sprite = UIAtlasMgr.Ins.Get_Sprite(m_Data.imgName_Off);
|
||
|
|
images[1].color = color_img_off;
|
||
|
|
}
|
||
|
|
if (texts.Length > 0) texts[0].color = color_text_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(); // 다음 실행
|
||
|
|
}
|
||
|
|
}
|