using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; [RequireComponent(typeof(Toggle))] public class SelectionChangeColor : MonoBehaviour { public TextMeshProUGUI showText; public Color normalColor; public Color selectColor; void Start() { GetComponent().onValueChanged.AddListener(selectChanged); if (GetComponent().isOn) { showText.color = selectColor; } else { showText.color = normalColor; } } private void selectChanged(bool Ison) { if (Ison) { showText.color = selectColor; } else { showText.color = normalColor; } } }