예제 #1
0
        public static void PreviewFade(RectTransform target, float from, float to, UIAnimation animation, float startAlpha)
        {
            switch (animation.AnimationType)
            {
            case AnimationType.Show:
            case AnimationType.Hide:
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.FadeTween(target, animation, @from, to), true, true, false);
                break;

            case AnimationType.Loop:
                CanvasGroup canvasGroup = target.GetComponent <CanvasGroup>() != null?target.GetComponent <CanvasGroup>() : target.gameObject.AddComponent <CanvasGroup>();

                animation.Fade.From = Mathf.Clamp01(animation.Fade.From);
                canvasGroup.alpha   = animation.Fade.From;
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.FadeLoopTween(target, animation), true, true, false);
                break;

            case AnimationType.State:
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.FadeStateTween(target, animation, startAlpha), true, true, false);
                break;
            }
        }