You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
806 B
39 lines
806 B
8 months ago
|
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<Toggle>().onValueChanged.AddListener(selectChanged);
|
||
|
if (GetComponent<Toggle>().isOn)
|
||
|
{
|
||
|
showText.color = selectColor;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
showText.color = normalColor;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void selectChanged(bool Ison)
|
||
|
{
|
||
|
if (Ison)
|
||
|
{
|
||
|
showText.color = selectColor;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
showText.color = normalColor;
|
||
|
}
|
||
|
}
|
||
|
}
|