IEnumerator AnimateIn() { Vector3 scale = transform.localScale; switch (inAnimation) { case Animation.ElasticGrowOut: yield return(gameObject.DoTween01(t => { transform.localScale = scale * PennerAnimation.ElasticEaseOut(t, 0, 1, 1); }, inTime)); break; default: break; } }
public static IEnumerator ElasticSlideInY(Transform t, float targetPosition, float animationTime) { float elapsedTime = 0; float startPosition = t.localPosition.y; while (elapsedTime < animationTime) { t.localPosition = new Vector2( t.localPosition.x, PennerAnimation.ElasticEaseOut(elapsedTime, startPosition, targetPosition - startPosition, animationTime) ); elapsedTime += Time.deltaTime; yield return(0); } t.localPosition = new Vector2( t.localPosition.x, targetPosition ); }
IEnumerator AnimateOut() { yield return(new WaitForSeconds(displayTime)); Vector3 scale = transform.localScale; switch (outAnimation) { case Animation.ElasticGrowOut: yield return(gameObject.DoTween01(t => { transform.localScale = scale * PennerAnimation.ElasticEaseOut(t, 1, -1, 1); }, outTime)); break; default: break; } gameObject.SetActive(false); }
override public IEnumerator Click() { float elapsedTime = 0; float initScale = 0.9f; float targetScale = 1.0f; float tweenTime = animationTime * 8.0f; clickTrigered = false; while (/*currentState == state.Click &&*/ elapsedTime < tweenTime) { float s = PennerAnimation.ElasticEaseOut(elapsedTime, initScale, targetScale - initScale, tweenTime); transform.localScale = pivotScale * s; elapsedTime += Time.unscaledDeltaTime; //elastic out is a bit slow to finish, we force click here. if (elapsedTime > tweenTime * 0.25f) { TrigerClick(); } yield return(0); } transform.localScale = pivotScale * targetScale; ChangeState(state.Idle); }