ToggleImageSelect.cs 484 B

12345678910111213141516171819202122
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class ToggleImageSelect : MonoBehaviour
  6. {
  7. public Toggle toggle;
  8. public GameObject ChecketImage;
  9. public Image backgroudImage;
  10. private void Start()
  11. {
  12. toggle = this.GetComponent<Toggle>();
  13. toggle.onValueChanged.AddListener((b) =>
  14. {
  15. ChecketImage.SetActive(b);
  16. backgroudImage.enabled = !b;
  17. });
  18. }
  19. }