Exemple #1
0
 public static void SetListener(this Toggle toggle, UnityAction <bool> action, IButtonSoundProvider soundProvider)
 {
     if (toggle == null)
     {
         return;
     }
     toggle.onValueChanged.RemoveAllListeners();
     toggle.onValueChanged.AddListener((isOn) => {
         soundProvider?.PlayButton();
         action?.Invoke(isOn);
     });
 }
Exemple #2
0
        public static void SetListener(this Button button, UnityAction action, IButtonSoundProvider soundProvider)
        {
            if (button == null)
            {
                return;
            }

            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(() => {
                soundProvider?.PlayButton();
                action?.Invoke();
            });
        }
Exemple #3
0
 public static void SetEventTriggerClick(this EventTrigger trigger, UnityAction <BaseEventData> onClick, IButtonSoundProvider soundProvider)
 {
     trigger?.triggers?.Clear();
     if (onClick != null)
     {
         EventTrigger.TriggerEvent clickEvent = new EventTrigger.TriggerEvent();
         clickEvent.AddListener((bed) => {
             soundProvider?.PlayButton();
             onClick?.Invoke(bed);
         });
         trigger?.triggers?.Add(new EventTrigger.Entry {
             eventID = EventTriggerType.PointerClick, callback = clickEvent
         });
     }
 }