Files
ChunilENG/Assets/WorkSpace/Personal/JYM/UI_DashboardCheckListItem.cs

112 lines
2.8 KiB
C#
Raw Normal View History

using TMPro;
using UnityEngine;
using UnityEngine.UI;
using WI;
namespace CHN
{
public class UI_DashboardCheckListItem : UIBase
{
private Toggle toggle;
private TextMeshProUGUI toggleText;
public GameObject dashboardItem;
public bool isClick => toggle.isOn;
private string keyName;
private string type;
public void SetItem(string name, GameObject item)
{
toggle = GetComponentInChildren<Toggle>();
toggleText = GetComponentInChildren<TextMeshProUGUI>();
keyName = name;
RefreshText();
dashboardItem = item;
type = Type();
var isBool = PlayerPrefs.GetInt(type) == 0 ? false : true;
toggle.isOn = isBool;
if(type != "isLibrary")
{
dashboardItem.gameObject.SetActive(isBool);
}
toggle.onValueChanged.AddListener(OnValueChange);
//LocaleService.Instance.OnChanged += OnChangeText;
}
//private void OnChangeText(object sender, Locale e)
//{
// if (e.name.Contains("ko"))
// {
// toggleText.fontSize = 14f;
// }
// else
// {
// toggleText.fontSize = 9f;
// }
// RefreshText();
//}
private void RefreshText()
{
toggleText.SetText(keyName);
}
public void ToggleOnItem()
{
toggle.isOn = true;
}
public void ToggleOffItem()
{
toggle.isOn = false;
}
private void OnValueChange(bool isOn)
{
PlayerPrefs.SetInt(type, isOn ? 1 : 0);
PlayerPrefs.Save();
if (type != "isLibrary")
{
dashboardItem.gameObject.SetActive(isOn);
}
else
{
var library = dashboardItem.gameObject.GetComponent<Panel_Library>();
if (isOn)
{
library.Open();
}
else
{
library.Close();
}
}
}
private string Type()
{
var type = "";
switch (keyName)
{
case ("<22>Ϸ<EFBFBD> <20>ð<EFBFBD> <20>˶<EFBFBD>"):
type = "isCompleteAlramHistory";
break;
case ("<22><><EFBFBD>̺귯<CCBA><EAB7AF>"):
type = "isLibrary";
break;
case ("<22>۾<EFBFBD> <20><><EFBFBD><EFBFBD> <20>м<EFBFBD>"):
type = "isWorkConditionAnalysis";
break;
case ("<22>۾<EFBFBD> <20>ð<EFBFBD> <20>м<EFBFBD>"):
type = "isWorkTimeAnalysis";
break;
}
return type;
}
}
}