using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; public class ButtonHoverEffect : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { private Image buttonImage; private Color originalColor; [SerializeField] [Range(0f, 1f)] private float hoverAlpha = 0.5f; // 0 = transparan, 1 = normal void Start() { buttonImage = GetComponent(); if (buttonImage != null) { originalColor = buttonImage.color; } } public void OnPointerEnter(PointerEventData eventData) { if (buttonImage != null) { Color c = originalColor; c.a = hoverAlpha; buttonImage.color = c; } } public void OnPointerExit(PointerEventData eventData) { if (buttonImage != null) { buttonImage.color = originalColor; } } }