using System; using UnityEngine; using UnityEngine.Events; public class ButtonRolloverHandler : MonoBehaviour { public SpriteRenderer Target; public Color OverColor = Color.green; public Color OutColor = Color.white; public AudioClip HoverSound; public void Start() { PassiveButton component = base.GetComponent(); component.OnMouseOver.AddListener(new UnityAction(this.DoMouseOver)); component.OnMouseOut.AddListener(new UnityAction(this.DoMouseOut)); } public void DoMouseOver() { this.Target.color = this.OverColor; if (this.HoverSound) { SoundManager.Instance.PlaySound(this.HoverSound, false, 1f); } } public void DoMouseOut() { this.Target.color = this.OutColor; } }