using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; [RequireComponent(typeof(Toggle))] public class SelectionChangeImage : MonoBehaviour { public GameObject normalImage; public GameObject selectImage; void Start() { GetComponent().onValueChanged.AddListener(selectChanged); normalImage.gameObject.SetActive(!GetComponent().isOn); selectImage.gameObject.SetActive(GetComponent().isOn); } private void selectChanged(bool Ison) { normalImage.gameObject.SetActive(!Ison); selectImage.gameObject.SetActive(Ison); } }