void Slide(float to)
        {
            if (anim.Animate(new UIAnimator.Slide(slideTime, to, () => {
                // Normalize positions
                inactiveContainer.RectTransform.SetAnchoredPositionX(0f);
                activeContainer.RectTransform.SetAnchoredPositionX(-to);
                RectTransform.SetAnchoredPositionX(0f);

                // Unload the previous view
                activeContainer.UnloadView();

                // Swap the active and inactive containers
                UpdateActiveContainer();

                // Inform the newly active container that the animation has finished & input is being accepted
                activeContainer.SetInputEnabled();

                // Enable the raycaster so that input is accepted again (small pause so that players don't accidently 'double press' buttons)
                Co.WaitForSeconds(0.05f, () => {
                    Raycaster.enabled = true;
                });
            })))
            {
                // Disable the raycaster while animating so that the user can't "double press" buttons
                Raycaster.enabled = false;
                inactiveContainer.RectTransform.SetAnchoredPositionX(-to);
            }
        }
Пример #2
0
 private void Animate(Func <bool> completion, float animationDuration, List <Sprite> sprites)
 {
     Setup();
     uiAnimator.Animate(UIAnimator.AnimationKey.Image, animationDuration, sprites, (animator) =>
     {
         completion?.Invoke();
         return(true);
     });
 }