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/VerticalGauge.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Client/Assembly-CSharp/VerticalGauge.cs (limited to 'Client/Assembly-CSharp/VerticalGauge.cs') diff --git a/Client/Assembly-CSharp/VerticalGauge.cs b/Client/Assembly-CSharp/VerticalGauge.cs new file mode 100644 index 0000000..08ebfec --- /dev/null +++ b/Client/Assembly-CSharp/VerticalGauge.cs @@ -0,0 +1,28 @@ +using System; +using UnityEngine; + +public class VerticalGauge : MonoBehaviour +{ + public float value = 0.5f; + + public float MaxValue = 1f; + + public float maskScale = 1f; + + public SpriteMask Mask; + + private float lastValue = float.MinValue; + + public void Update() + { + if (this.lastValue != this.value) + { + this.lastValue = this.value; + float num = Mathf.Clamp(this.lastValue / this.MaxValue, 0f, 1f) * this.maskScale; + Vector3 localScale = this.Mask.transform.localScale; + localScale.y = num; + this.Mask.transform.localScale = localScale; + this.Mask.transform.localPosition = new Vector3(0f, -this.Mask.sprite.bounds.size.y * (this.maskScale - num) / 2f, 0f); + } + } +} -- cgit v1.1-26-g67d0