private void CreateAccumulatedText(double val, bool isManual) { if (textPull.HasObject) { float duration = 1; //isManual ? 0.6f : 0.3f; GameObject inst = textPull.UseAtPosition(new Vector2(UnityEngine.Random.Range(0, 330), -353)); //Instantiate(AccumulatedTextPrefab, transform, false); Text txt = inst.GetComponent <Text>(); txt.text = val.ToCurrencyNumber().PrefixedAbbreviation(); RectTransform textTrs = inst.GetComponent <RectTransform>(); float finalDuration = duration + UnityEngine.Random.Range(-.2f, .2f); Vector2Animator vec2Animator = inst.GetComponent <Vector2Animator>(); vec2Animator.StartAnimation(new Vector2AnimationData { StartValue = textTrs.anchoredPosition, EndValue = textTrs.anchoredPosition + Vector2.down * 5 /* + Vector2.up * 60*/, Duration = finalDuration, EaseType = EaseType.EaseInOutQuad, Target = inst, OnStart = textTrs.UpdatePositionFunctor(), OnUpdate = textTrs.UpdatePositionTimedFunctor(), OnEnd = textTrs.UpdatePositionFunctor(() => textPull.Free(inst)) }); FloatAnimator alphaAnimator = inst.GetComponent <FloatAnimator>(); CanvasGroup cg = inst.GetComponent <CanvasGroup>(); alphaAnimator.Stop(); cg.alpha = 1; alphaAnimator.StartAnimation(new FloatAnimationData { Duration = finalDuration * 1.5f, EaseType = EaseType.EaseInOutQuad, StartValue = 1, EndValue = 0, Target = inst, OnStart = cg.UpdateAlphaFunctor(), OnUpdate = cg.UpdateAlphaTimedFunctor(), OnEnd = cg.UpdateAlphaFunctor() }); Vector3Animator v3animator = inst.GetOrAdd <Vector3Animator>(); v3animator.Stop(); v3animator.StartAnimation(textTrs.ConstructScaleAnimationData(Vector3.one * .1f, Vector3.one, finalDuration * 0.5f, BosAnimationMode.Single, EaseType.EaseInOutQuad, () => { v3animator.StartAnimation(textTrs.ConstructScaleAnimationData(Vector3.one, Vector3.one * .1f, finalDuration * 0.5f, BosAnimationMode.Single, EaseType.EaseInOutQuad)); })); //ColorAnimator colorAnimator = inst.GetComponent<ColorAnimator>(); //colorAnimator.StartAnimation(AnimUtils.GetColorAnimData(txt.color, txt.color.ChangeAlpha(0), finalDuration, EaseType.EaseInOutQuad, textTrs)); } }
private void Animate() { Vector3Animator animator = gameObject.GetOrAdd <Vector3Animator>(); animator.Stop(); animator.StartAnimation(new Vector3AnimationData { StartValue = startValue, EndValue = endValue, Duration = duration, EaseType = easeType, AnimationMode = mode, Target = gameObject, OnStart = rectTransform.UpdateScaleFunctor(), OnUpdate = rectTransform.UpdateScaleTimedFunctor(), OnEnd = rectTransform.UpdateScaleFunctor() }); }