ChooseText.cs 389 B

1234567891011121314151617
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class ChooseText : MonoBehaviour
  6. {
  7. public Color ncolor;
  8. public Color ccolor;
  9. private void Awake() {
  10. this.transform.parent.GetComponent<Toggle>().onValueChanged.AddListener((b)=>{
  11. this.GetComponent<Text>().color = b?ccolor:ncolor;
  12. });
  13. }
  14. }