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/TransitionOpen.cs | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Client/Assembly-CSharp/TransitionOpen.cs (limited to 'Client/Assembly-CSharp/TransitionOpen.cs') 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; + } +} -- cgit v1.1-26-g67d0