LuJingItem.cs 578 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class LuJingItem : MonoBehaviour
  7. {
  8. public event Action<int, bool> OnToggleSelect;
  9. public Toggle Toggle;
  10. public int Index { get; set; }
  11. private void Awake()
  12. {
  13. Toggle = GetComponent<Toggle>();
  14. Toggle.onValueChanged.AddListener(OnToggleValueChange);
  15. }
  16. private void OnToggleValueChange(bool ison)
  17. {
  18. if (OnToggleSelect != null)
  19. {
  20. OnToggleSelect(Index, ison);
  21. }
  22. }
  23. }