public void StartCountDown(Action onEndCountDown, Action onNoThanks) { if (countDownCoroutine != null) { StopCoroutine(countDownCoroutine); } noThanksButton.OnClickEvent.RemoveAllListeners(); noThanksButton.AddListener(() => { if (onNoThanks != null) { onNoThanks.Invoke(); } }); countDownCoroutine = StartCoroutine(KKUtilities.FloatLerp(timeLimit, (t) => { timeLimitGauge.Image.fillAmount = 1.0f - t; }).OnCompleted(() => { if (onEndCountDown != null) { onEndCountDown.Invoke(); } gameObject.SetActive(false); countDownCoroutine = null; })); }
public static Coroutine Fade(this UGUIParts self, float duration, float targetAlpha) { var startAlpha = self.Alpha; return(self.StartCoroutine(KKUtilities.FloatLerp(duration, (t) => { self.Alpha = Mathf.Lerp(startAlpha, targetAlpha, Easing.InQuad(t)); }))); }
public static Coroutine LocalMove(this MonoBehaviour mono, float duration, Vector3 targetPos, EaseType ease, bool isScalable = true) { Vector3 startPos = mono.transform.localPosition; return(mono.StartCoroutine(KKUtilities.FloatLerp(duration, (t) => { mono.transform.localPosition = Vector3.LerpUnclamped(startPos, targetPos, Easing.GetEase(t, ease)); }, isScalable))); }
public static Coroutine PopUp(this UGUIParts self, float duration) { self.transform.localScale = Vector3.zero; self.gameObject.SetActive(true); return(self.StartCoroutine(KKUtilities.FloatLerp(duration, (t) => { self.transform.localScale = Vector3.LerpUnclamped(Vector3.zero, Vector3.one, Easing.OutBack(t)); }))); }
protected override IEnumerator TutorialAnimation() { while (true) { yield return(KKUtilities.FloatLerp(speed, (t) => { fingerImage.RectTransform.anchoredPosition = Vector2.LerpUnclamped(startPoint.anchoredPosition, endPoint.anchoredPosition, curve.Evaluate(t)); })); } }
public void HideMenu() { StopAllCoroutines(); StartCoroutine(KKUtilities.FloatLerp(0.3f, (t) => { container.alpha = Mathf.Lerp(1.0f, 0.0f, t); }).OnCompleted(() => { container.gameObject.SetActive(false); })); }
protected override IEnumerator TutorialAnimation() { float maxScale = 1.2f; while (true) { yield return(KKUtilities.FloatLerp(speed, (t) => { fingerImage.transform.localScale = Vector3.Lerp(Vector3.one, Vector3.one * maxScale, curve.Evaluate(t)); })); } }
void ChangeVolume(float startVolume, float endVolume, float duration, Action callback = null) { StartCoroutine(KKUtilities.FloatLerp(duration, (t) => { Volume = Mathf.Lerp(startVolume, endVolume, t); }).OnCompleted(() => { if (callback != null) { callback.Invoke(); } })); }
public virtual void Hide() { StartCoroutine(KKUtilities.FloatLerp(showAnimationTime * 0.5f, (t) => { panel.Alpha = Mathf.Lerp(panel.DefaultAlpha, 0.0f, Easing.OutQuad(t)); })); StartCoroutine(hideAnimation.GetAnimation(this, hideAnimationTime).OnCompleted(() => { panel.gameObject.SetActive(false); Container.SetActive(false); OnHideAnimationEnd.Invoke(); })); }
IEnumerator NotificationAnimation() { var wait = new WaitForSeconds(0.75f); while (true) { yield return(KKUtilities.FloatLerp(2.0f, (t) => { transform.localScale = Vector3.LerpUnclamped(Vector3.one, Vector3.one * 1.2f, scaleCurve.Evaluate(t)); })); yield return(wait); } }
public virtual void Show() { panel.gameObject.SetActive(true); Container.SetActive(true); Alpha = 1; StartCoroutine(KKUtilities.FloatLerp(showAnimationTime * 0.5f, (t) => { panel.Alpha = Mathf.Lerp(0.0f, panel.DefaultAlpha, Easing.InQuad(t)); })); StartCoroutine(showAnimation.GetAnimation(this, showAnimationTime).OnCompleted(() => { OnShowAnimationEnd.Invoke(); })); }
protected override void OnClick() { Button.interactable = false; Vector3 startPos = buttonImage.transform.position; Vector3 endPos = shadowImage.transform.position; StartCoroutine(KKUtilities.FloatLerp(0.15f, (t) => { buttonImage.transform.position = Vector3.Lerp(startPos, endPos, Easing.Yoyo(t)); }, false).OnCompleted(() => { base.OnClick(); Button.interactable = true; })); }
IEnumerator Fade(Color startColor, Color endColor, float duration, Action endCallback, bool finishedPanelActive) { panel.color = startColor; panel.gameObject.SetActive(true); yield return(StartCoroutine(KKUtilities.FloatLerp(duration, (t) => { panel.color = Color.Lerp(startColor, endColor, t); }) )); fadeCoroutine = null; panel.gameObject.SetActive(finishedPanelActive); if (endCallback != null) { endCallback.Invoke(); } }
void ChangeStateAnimation() { StopAllCoroutines(); var start = circle.RectTransform.anchoredPosition; var end = IsOn ? selectedCirclePosition : unSelectedCirclePosition; if (!gameObject.activeInHierarchy) { Refresh(); return; } AudioManager.Instance.PlaySE("Click", 0.3f); StartCoroutine(KKUtilities.FloatLerp(0.15f, (t) => { circle.RectTransform.anchoredPosition = Vector2.Lerp(start, end, Easing.OutQuad(t)); }).OnCompleted(() => { Refresh(); })); }
public MyCoroutine GetAnimation(UIParts parts, float duration) { return(new MyCoroutine(KKUtilities.FloatLerp(duration, (t) => logic(parts, t)))); }
/// <summary> /// 与えられたActionにduration秒かけて0→1になる値を毎フレーム渡す /// </summary> public static Coroutine FloatLerp(this MonoBehaviour mono, float duration, Action <float> action, bool isScalable = true) { return(mono.StartCoroutine(KKUtilities.FloatLerp(duration, action, isScalable))); }