diff options
author | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
commit | e9ea621b93fbb58d9edfca8375918791637bbd52 (patch) | |
tree | 19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/ButtonRolloverHandler.cs |
+init
Diffstat (limited to 'Client/Assembly-CSharp/ButtonRolloverHandler.cs')
-rw-r--r-- | Client/Assembly-CSharp/ButtonRolloverHandler.cs | 35 |
1 files changed, 35 insertions, 0 deletions
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<PassiveButton>(); + 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; + } +} |