private void AnimateCoin(RectTransform coinRectTransform, float startDelay, int setCoinAmountTextTo) { RectTransform coinToAnimate = coinPool.GetObject <RectTransform>(); UIAnimation.DestroyAllAnimations(coinToAnimate.gameObject); // 需要将coinToAnimate的比例设置为与coinRectTransform相同的比例 coinToAnimate.SetParent(coinRectTransform.parent, false); coinToAnimate.sizeDelta = coinRectTransform.sizeDelta; coinToAnimate.localScale = coinRectTransform.localScale; coinToAnimate.anchoredPosition = coinRectTransform.anchoredPosition; coinToAnimate.SetParent(animationContainer); Vector2 animateToPosition = SwitchToRectTransform(animateTo, animationContainer); // 指定硬币的x位置上的动画 PlayAnimation(UIAnimation.PositionX(coinToAnimate, animateToPosition.x, animationDuration), startDelay); // 指定硬币的y位置上的动画 PlayAnimation(UIAnimation.PositionY(coinToAnimate, animateToPosition.y, animationDuration), startDelay); // 指定硬币的x缩放上的动画 PlayAnimation(UIAnimation.ScaleX(coinToAnimate, 1, animationDuration), startDelay); // 指定硬币的y缩放上的动画 PlayAnimation(UIAnimation.ScaleY(coinToAnimate, 1, animationDuration), startDelay); // 指定硬币宽度上的动画 PlayAnimation(UIAnimation.Width(coinToAnimate, animateTo.sizeDelta.x, animationDuration), startDelay); // 指定硬币长度上的动画 PlayAnimation(UIAnimation.Height(coinToAnimate, animateTo.sizeDelta.y, animationDuration), startDelay); StartCoroutine(WaitThenSetCoinsText(setCoinAmountTextTo, animationDuration + startDelay)); }
private IEnumerator StartPulse(Vector2 origScale, int pulseAmount, float pulseForce, float pulseAnimDuration) { for (int i = 0; i < pulseAmount; i++) { UIAnimation.ScaleX(transform as RectTransform, origScale.x * pulseForce, pulseAnimDuration / 2f).Play(); UIAnimation.ScaleY(transform as RectTransform, origScale.y * pulseForce, pulseAnimDuration / 2f).Play(); yield return(new WaitForSeconds(pulseAnimDuration / 2f)); UIAnimation.ScaleX(transform as RectTransform, origScale.x, pulseAnimDuration / 2f).Play(); UIAnimation.ScaleY(transform as RectTransform, origScale.y, pulseAnimDuration / 2f).Play(); yield return(new WaitForSeconds(pulseAnimDuration / 2f)); } pulseRoutine = null; }
private void DoZoomAnim() { // Start the popup show animations UIAnimation anim = null; anim = UIAnimation.Alpha(gameObject, 0f, 1f, animDuration); anim.style = UIAnimation.Style.EaseOut; anim.startOnFirstFrame = true; anim.OnAnimationFinished = null; anim.Play(); anim = UIAnimation.ScaleX(animContainer, 0f, 1f, animDuration); anim.style = UIAnimation.Style.Custom; anim.animationCurve = animCurve; anim.startOnFirstFrame = true; anim.Play(); anim = UIAnimation.ScaleY(animContainer, 0f, 1f, animDuration); anim.style = UIAnimation.Style.Custom; anim.animationCurve = animCurve; anim.startOnFirstFrame = true; anim.Play(); }