protected Vector2 Ease(MadiTween.EaseType type, Vector2 start, Vector2 end, float percentage) { var fun = MadiTween.GetEasingFunction(type); float x = fun(start.x, end.x, percentage); float y = fun(start.y, end.y, percentage); return(new Vector2(x, y)); }
protected MadiTween.EasingFunction GetEasingFunction() { if (useAnimationCurve) { return(EasingFromCurve); } else { return(MadiTween.GetEasingFunction(easing)); } }
protected override void Start() { sprite = GetComponent <MadSprite>(); if (sprite == null) { Debug.Log("Anim Color component requires MadSprite component!", this); return; } origin = sprite.tint; easingFunction = MadiTween.GetEasingFunction(easing); base.Start(); }
public IEnumerator Anim() { while (enabled) { // infinite animation coroutine var visibleCount = barRenderer.GetVisibleIconCount(); if (visibleCount > 0) { var image = barRenderer.GetIconImage(visibleCount - 1); // make a copy var clone = (Image2) Instantiate(image); // changing the name, because "generated_*" icons are treated in a special way and this may lead to errors clone.name = "anim icon"; clone.transform.SetParent(image.transform.parent, false); clone.transform.position = image.transform.position; clone.transform.SetSiblingIndex(image.transform.GetSiblingIndex()); // do the animation float startTime = Time.time; float endTime = Time.time + animationTime; var easingFunction = MadiTween.GetEasingFunction(scaleEaseType); while (Time.time < endTime) { float f = (Time.time - startTime) / animationTime; var scale = easingFunction.Invoke(scaleFrom, scaleTo, f); clone.transform.localScale = new Vector3(scale, scale, scale); var alpha = easingFunction.Invoke(alphaFrom, alphaTo, f); clone.color = new Color(clone.color.r, clone.color.g, clone.color.b, alpha); yield return null; // next frame } // remove Destroy(clone.gameObject); } else { // if there's no last icon, just wait yield return new WaitForSeconds(animationTime); } } }
protected override void Start() { easingFunction = MadiTween.GetEasingFunction(easing); base.Start(); }