using System.Collections; using System.Collections.Generic; using DG.Tweening.Core.Easing; using Ichni; using UnityEngine; public static class WindowAnim { public static IEnumerator ShowPanelOnScale(GameObject gameObject) { AnimationCurve animationCurve = new AnimationCurve( new Keyframe(0, 0), new Keyframe(0.25f, 0.55f), new Keyframe(0.5f, 0.85f), new Keyframe(0.75f, 0.97f), new Keyframe(1, 1) ); float timer = 0; while (timer <= 1) { gameObject.transform.localScale = Vector3.one * animationCurve.Evaluate(timer); timer += Time.deltaTime * 5f; yield return null; } gameObject.transform.localScale = Vector3.one; } public static IEnumerator HidePanelOnscale(GameObject gameObject, bool DestoryOrNot = false) { AnimationCurve animationCurve = new AnimationCurve( new Keyframe(0, 0), new Keyframe(0.25f, 0.55f), new Keyframe(0.5f, 0.85f), new Keyframe(0.75f, 0.97f), new Keyframe(1, 1) ); float timer = 1; while (timer >= 0) { gameObject.transform.localScale = Vector3.one * animationCurve.Evaluate(timer); timer += Time.deltaTime * 5f; yield return null; } gameObject.transform.localScale = Vector3.zero; } public static IEnumerator Shake(GameObject gameObject) { float timer = 0f; Vector3 origpos = gameObject.transform.position; while (timer <= 1f) { float offset = 50 * AnimationCurveEvaluator.Evaluate(AnimationCurveType.OutElastic, timer / 1f); gameObject.transform.position = origpos + new Vector3(Random.Range(-offset, offset), Random.Range(-offset, offset), 0); timer += Time.deltaTime; yield return null; } gameObject.transform.position = origpos; } }