using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Sirenix.OdinInspector; using KairoEngine.SFX; using UnityEngine.EventSystems; namespace KairoEngine.UI.SFX { [HideMonoScript] public class ButtonSFX : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler { public Button button; public SFXClip onPointerEnterSFX; public SFXClip onPointerExitSFX; public SFXClip onPointerDownSFX; public SFXClip onPointerUpSFX; public SFXClip onClickSFX; public void OnPointerEnter(PointerEventData eventData) { if(MouseInputUIBlocker.BlockedByUI) return; PlaySFX(onPointerEnterSFX); } public void OnPointerExit(PointerEventData eventData) { PlaySFX(onPointerExitSFX); } public void OnPointerDown(PointerEventData eventData) { if(MouseInputUIBlocker.BlockedByUI) return; PlaySFX(onPointerDownSFX); } public void OnPointerUp(PointerEventData eventData) { PlaySFX(onPointerUpSFX); } public void OnMouseEnter() { if(MouseInputUIBlocker.BlockedByUI) return; PlaySFX(onPointerEnterSFX); } public void OnMouseExit() { PlaySFX(onPointerExitSFX); } public void OnMouseDown() { if(MouseInputUIBlocker.BlockedByUI) return; PlaySFX(onPointerDownSFX); } public void OnMouseUp() { PlaySFX(onPointerUpSFX); } public void OnClick() { PlaySFX(onClickSFX); } private void PlaySFX(SFXClip clip) { if(clip == null) return; if(this.gameObject.activeInHierarchy == false) return; if(button != null) { if(button.interactable == false) return; } SoundController.EmmitSound(clip, new Vector3()); } } }