From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/ButtonRolloverHandler.cs | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Client/Assembly-CSharp/ButtonRolloverHandler.cs (limited to 'Client/Assembly-CSharp/ButtonRolloverHandler.cs') diff --git a/Client/Assembly-CSharp/ButtonRolloverHandler.cs b/Client/Assembly-CSharp/ButtonRolloverHandler.cs new file mode 100644 index 0000000..963058d --- /dev/null +++ b/Client/Assembly-CSharp/ButtonRolloverHandler.cs @@ -0,0 +1,35 @@ +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; + } +} -- cgit v1.1-26-g67d0