Files
ZHGD_Web/Assets/Scripts/UI/Other/ToggleGroupSelf.cs

31 lines
795 B
C#
Raw Normal View History

2025-07-13 23:16:20 +08:00
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ToggleGroupSelf : MonoBehaviour
{
public Color m_ActiveColor;
public Color m_UnActiveColor;
public List<Toggle> m_SelfToggles = new List<Toggle>();
// Start is called before the first frame update
void Start()
{
foreach (Toggle item in m_SelfToggles)
{
item.onValueChanged.AddListener((b) =>
{
item.GetComponentInChildren<TextMeshProUGUI>().color = b ? m_ActiveColor : m_UnActiveColor;
item.GetComponentInChildren<TextMeshProUGUI>().fontSize = b ? 24 : 22;
});
}
}
// Update is called once per frame
void Update()
{
}
}