using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; [RequireComponent(typeof(Toggle))] public class SetToggleImage : MonoBehaviour { private Toggle toggle; public Image image; // Use this for initialization void Start () { toggle = GetComponent(); toggle.onValueChanged.AddListener(ValueChanged); } // Update is called once per frame void Update () { } private void ValueChanged(bool isOn) { image.enabled = !isOn; } }