void Squeeze(float t, Vector3 pivotScale) { float sx = PennerAnimation.CubicEaseInOut(t, pivotScale.x * 1 - changeInValue, pivotScale.x * changeInValue, 1); float sy = PennerAnimation.CubicEaseInOut(1 - t, pivotScale.y * 1 - changeInValue, pivotScale.y * changeInValue, 1); transform.localScale = new Vector3(sx, sy, pivotScale.z); }
IEnumerator showView(RectTransform holder, states state) { loadingPopup.anchoredPosition = Vector3.down * screenOffset; messagePopup.anchoredPosition = Vector3.down * screenOffset; choosePopup.anchoredPosition = Vector3.down * screenOffset; Canvas.ForceUpdateCanvases(); yield return(this.DoUnscaledTween01(t => { //loadingPopup.localScale = Vector3.one * PennerAnimation.QuadEaseInOut(t, 0, 1, 1); holder.localPosition = new Vector3( 0, PennerAnimation.BackEaseOut(t, -screenOffset, screenOffset, 1), 0 ); }, 0.75f)); background.interactable = true; background.blocksRaycasts = true; while (fsm.currentState == state) { yield return(0); } this.DoUnscaledTween01(t => { //loadingPopup.localScale = Vector3.one * PennerAnimation.QuadEaseInOut(t, 1, -1, 1); holder.localPosition = new Vector3( 0, PennerAnimation.BackEaseIn(t, 0, screenOffset, 1), 0 ); }, 0.5f); }
IEnumerator FadeOutAndLoad(string sceneName, float animationTime, float waitTime, Action callback = null) { fadeCanvasGroup.alpha = 0; if (loadingText != null) { loadingText.gameObject.SetActive(true); } yield return(this.DoUnscaledTween01(t => { if (music != null) { music.volume = PennerAnimation.CubicEaseOut(t, 0, 1, 1); } fadeCanvasGroup.alpha = PennerAnimation.QuadEaseInOut(t, 0, 1, 1); }, animationTime, () => { callback?.Invoke(); })); fadeCanvasGroup.alpha = 1.0f; if (music != null) { music.volume = 0; } if (waitTime > 0) { yield return(new WaitForSeconds(waitTime)); } SceneManager.LoadScene(sceneName); }
override public IEnumerator Select() { float elapsedTime = 0; float animationTime = 0.5f; while (currentState == state.Select && elapsedTime < animationTime) { float scale = PennerAnimation.BackEaseOut(elapsedTime / animationTime, 0, 1, 1); transform.localScale = pivotScale + Vector3.one * 0.25f * scale; elapsedTime += Time.unscaledDeltaTime; yield return(0); } transform.localScale = pivotScale + Vector3.one * 0.25f; while (currentState == state.Select) { yield return(0); } yield return(gameObject.DoUnscaledTween01(t => { float scale = PennerAnimation.QuadEaseIn(t, 1, -1, 1); transform.localScale = pivotScale + Vector3.one * 0.25f * scale; }, 0.1f)); }
void Rock(float t, Quaternion pivotRotation) { Vector3 angles = pivotRotation.eulerAngles; float z = PennerAnimation.CubicEaseInOut(t, 0, 1, 1); angles.z = (z - 0.5f) * changeInValue; transform.localRotation = Quaternion.Euler(angles); }
IEnumerator FadeIn(float animationTime) { fadeCanvasGroup.alpha = 1.0f; yield return(new WaitForSeconds(fadeInDelay)); yield return(this.DoTween01(t => { fadeCanvasGroup.alpha = PennerAnimation.QuadEaseInOut(t, 1, -1, 1); }, animationTime)); }
public static IEnumerator Translate(Transform tr, float randomOffsetMin, float randomOffsetMax, float animationTime, Vector3 from, Vector3 to) { float elapsedTime = 0; while (elapsedTime < animationTime) { float t = PennerAnimation.QuadEaseInOut(elapsedTime, 0, 1, animationTime); tr.position = Vector3.Lerp(from, to, t); elapsedTime += Time.deltaTime; yield return(0); } tr.position = to; }
public static IEnumerator EaseBackOutScaleFromTo(RectTransform t, float f, float to, float animationTime) { float elapsedTime = 0; while (elapsedTime < animationTime) { t.localScale = Vector3.one * PennerAnimation.BackEaseOut(elapsedTime, f, to - f, animationTime); elapsedTime += Time.deltaTime; yield return(0); } t.localScale = Vector3.one * to; }
public static IEnumerator ElasticGrowth(Transform t, float randomOffsetMin, float randomOffsetMax, float animationTime) { yield return(new WaitForSeconds(randomOffsetMin + Random.value * randomOffsetMax)); float elapsedTime = 0; while (elapsedTime < animationTime) { float s = PennerAnimation.BounceEaseOut(elapsedTime, 0, 1, animationTime); t.localScale = Vector3.one * s; elapsedTime += Time.deltaTime; yield return(0); } t.localScale = Vector3.one; }
public static IEnumerator FallRectTransform(RectTransform rt, float randomOffsetMin, float randomOffsetMax, float animationTime, Vector3 to) { float elapsedTime = 0; Vector3 from = to + Vector3.up * Screen.height * 2; rt.anchoredPosition = from; while (elapsedTime < animationTime) { float t = PennerAnimation.BounceEaseOut(elapsedTime, 0, 1, animationTime); rt.anchoredPosition = Vector3.Lerp(from, to, t); elapsedTime += Time.deltaTime; yield return(0); } rt.anchoredPosition = to; }
override public IEnumerator Press() { float elapsedTime = 0; while (currentState == state.Press && elapsedTime < animationTime) { float s = PennerAnimation.CubicEaseInOut(elapsedTime, 1f, scaleFactor, animationTime); transform.localScale = pivotScale * s; elapsedTime += Time.unscaledDeltaTime; yield return(0); } transform.localScale = pivotScale * (1 + scaleFactor); while (currentState == state.Press) { yield return(0); } }
override public IEnumerator Release() { float elapsedTime = 0; float initScale = 1 + scaleFactor; while (currentState == state.Release && elapsedTime < animationTime) { float s = PennerAnimation.CubicEaseInOut(elapsedTime, initScale, -scaleFactor, animationTime); transform.localScale = pivotScale * s; elapsedTime += Time.unscaledDeltaTime; yield return(0); } transform.localScale = pivotScale; if (currentState == state.Release) { ChangeState(state.Idle); } }
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 BackEaseSlideInX(RectTransform rt, float targetPosition, float animationTime) { float elapsedTime = 0; float startPosition = rt.anchoredPosition.x; while (elapsedTime < animationTime) { rt.anchoredPosition = new Vector2( PennerAnimation.BackEaseInOut(elapsedTime, startPosition, targetPosition - startPosition, animationTime), rt.anchoredPosition.y ); elapsedTime += Time.deltaTime; yield return(0); } rt.anchoredPosition = new Vector2( targetPosition, rt.anchoredPosition.y ); }
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 ); }
public static IEnumerator CubicSlideOutY(RectTransform rt, float targetPosition, float animationTime) { float elapsedTime = 0; float startPosition = rt.anchoredPosition.y; while (elapsedTime < animationTime) { rt.anchoredPosition = new Vector2( rt.anchoredPosition.x, PennerAnimation.CubicEaseIn(elapsedTime, startPosition, targetPosition - startPosition, animationTime) ); elapsedTime += Time.deltaTime; yield return(0); } rt.anchoredPosition = new Vector2( rt.anchoredPosition.x, targetPosition ); }
override public IEnumerator Press() { float elapsedTime = 0; float initScale = 1.0f; float targetScale = 0.9f; while (currentState == state.Press && elapsedTime < animationTime) { float s = PennerAnimation.CubicEaseInOut(elapsedTime, initScale, targetScale - initScale, animationTime); transform.localScale = pivotScale * s * scaleFactor; elapsedTime += Time.unscaledDeltaTime; yield return(0); } transform.localScale = pivotScale * targetScale * scaleFactor; while (currentState == state.Press) { yield return(0); } }
public static IEnumerator EaseOutShake(Transform target, float animationTime, float strength) { Vector3 pivotPosition = target.localPosition; float elapsedTime = 0; while (elapsedTime < animationTime) { Vector3 p = pivotPosition + Random.insideUnitSphere * PennerAnimation.CubicEaseOut( elapsedTime, 0, strength, animationTime); target.localPosition = p; elapsedTime += Time.deltaTime; yield return(0); } target.localPosition = pivotPosition; }
public static IEnumerator CubicFade(Image target, float start, float end, float animationTime) { float elapsedTime = 0; Color c = Color.white; while (elapsedTime < animationTime) { c.a = PennerAnimation.CubicEaseIn( elapsedTime, start, end - start, animationTime ); target.color = c; elapsedTime += Time.deltaTime; yield return(0); } c.a = end; target.color = c; }
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 = 1 + scaleFactor; float tweenTime = animationTime * 3.0f; clickTrigered = false; while (/*currentState == state.Click &&*/ elapsedTime < tweenTime) { float s = PennerAnimation.CubicEaseOut(elapsedTime, initScale, -scaleFactor, tweenTime); transform.localScale = pivotScale * s; elapsedTime += Time.unscaledDeltaTime; //elastic out is a bit slow to finish, we force click here. if (elapsedTime > tweenTime * 0.35f) { TrigerClick(); } yield return(0); } transform.localScale = pivotScale; ChangeState(state.Idle); }
void HoverOnZ(float t, Vector3 pivotLocation) { float sz = PennerAnimation.QuadEaseInOut(t, pivotLocation.z, changeInValue, 1); transform.localPosition = new Vector3(pivotLocation.x, pivotLocation.z, sz); }
void Sway(float t, Vector3 pivotLocation) { float sx = PennerAnimation.QuadEaseInOut(t, pivotLocation.x, changeInValue, 1); transform.localPosition = new Vector3(sx, pivotLocation.y, pivotLocation.z); }