123456789101112131415161718192021222324252627 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.UI;
- [RequireComponent(typeof(Toggle))]
- public class TogglEvent : MonoBehaviour
- {
- private Toggle m_Toggle = null;
- [SerializeField] private UnityEvent m_OnToggleTrue = new UnityEvent();
- [SerializeField] private UnityEvent m_OnToggleFalse = new UnityEvent();
- // Start is called before the first frame update
- void Start() {
- m_Toggle = GetComponent<Toggle>();
- m_Toggle.onValueChanged.AddListener((v) => {
- if (v) {
- m_OnToggleTrue.Invoke();
- }
- else {
- m_OnToggleFalse.Invoke();
- }
- });
- }
- }
|