using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; namespace Michsky.UI.Shift { [ExecuteInEditMode] public class UIElementSound : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler { [Header("Resources")] public UIManager UIManagerAsset; public AudioSource audioObject; [Header("Custom SFX")] public AudioClip hoverSFX; public AudioClip clickSFX; [Header("Settings")] public bool enableHoverSound = true; public bool enableClickSound = true; public bool checkForInteraction = true; private Button sourceButton; void OnEnable() { if (UIManagerAsset == null) { try { UIManagerAsset = Resources.Load("Shift UI Manager"); } catch { Debug.Log("[UI Element Sound] No UI Manager found.", this); this.enabled = false; } } if (Application.isPlaying == true && audioObject == null) { try { audioObject = GameObject.Find("UI Audio").GetComponent(); } catch { Debug.Log("[UI Element Sound] No Audio Source found.", this); } } if (checkForInteraction == true) { sourceButton = gameObject.GetComponent