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/HorizontalGauge.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Client/Assembly-CSharp/HorizontalGauge.cs (limited to 'Client/Assembly-CSharp/HorizontalGauge.cs') diff --git a/Client/Assembly-CSharp/HorizontalGauge.cs b/Client/Assembly-CSharp/HorizontalGauge.cs new file mode 100644 index 0000000..2995903 --- /dev/null +++ b/Client/Assembly-CSharp/HorizontalGauge.cs @@ -0,0 +1,26 @@ +using System; +using UnityEngine; + +public class HorizontalGauge : 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.MaxValue != 0f && this.lastValue != this.Value) + { + this.lastValue = this.Value; + float num = this.lastValue / this.MaxValue * this.maskScale; + this.Mask.transform.localScale = new Vector3(num, 1f, 1f); + this.Mask.transform.localPosition = new Vector3(-this.Mask.sprite.bounds.size.x * (this.maskScale - num) / 2f, 0f, 0f); + } + } +} -- cgit v1.1-26-g67d0