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/TransitionOpen.cs |
+init
Diffstat (limited to 'Client/Assembly-CSharp/TransitionOpen.cs')
-rw-r--r-- | Client/Assembly-CSharp/TransitionOpen.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/TransitionOpen.cs b/Client/Assembly-CSharp/TransitionOpen.cs new file mode 100644 index 0000000..b846e44 --- /dev/null +++ b/Client/Assembly-CSharp/TransitionOpen.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections; +using UnityEngine; +using UnityEngine.UI; + +public class TransitionOpen : MonoBehaviour +{ + public float duration = 0.2f; + + public Button.ButtonClickedEvent OnClose = new Button.ButtonClickedEvent(); + + public void OnEnable() + { + base.StartCoroutine(this.AnimateOpen()); + } + + public void Close() + { + base.StartCoroutine(this.AnimateClose()); + } + + private IEnumerator AnimateClose() + { + Vector3 vec = default(Vector3); + for (float t = 0f; t < this.duration; t += Time.deltaTime) + { + float t2 = t / this.duration; + float num = Mathf.SmoothStep(1f, 0f, t2); + vec.Set(num, num, num); + base.transform.localScale = vec; + yield return null; + } + vec.Set(0f, 0f, 0f); + base.transform.localScale = vec; + this.OnClose.Invoke(); + yield break; + } + + private IEnumerator AnimateOpen() + { + Vector3 vec = default(Vector3); + for (float t = 0f; t < this.duration; t += Time.deltaTime) + { + float t2 = t / this.duration; + float num = Mathf.SmoothStep(0f, 1f, t2); + vec.Set(num, num, num); + base.transform.localScale = vec; + yield return null; + } + vec.Set(1f, 1f, 1f); + base.transform.localScale = vec; + yield break; + } +} |