예제 #1
0
        // Moves the button to the given position over time
        private IEnumerator MoveButtonTo(Vector2 position)
        {
            yield return(Routine.Combine(

                             // Move the button to the position
                             m_ButtonTransform.AnchorPosTo(position, m_CurrentInterval / 5).Ease(Curve.CubeOut),

                             // Sure, let's spin the button as well
                             m_ButtonTransform.RotateTo(360f, m_CurrentInterval / 5, Axis.Z, Space.Self, AngleMode.Absolute).Ease(Curve.CubeOut).RevertOnCancel()
                             ));
        }
예제 #2
0
    private IEnumerator FadeOut()
    {
        // Prevent the user from interacting
        m_RootGroup.interactable = false;
        m_ButtonSpinAnimation.Stop();

        // Perform the animation
        yield return(Routine.Combine(
                         m_RootGroup.FadeTo(0f, m_FadeSettings)
                         ));

        // Deactivate the menu
        m_RootGroup.gameObject.SetActive(false);
    }
예제 #3
0
    private IEnumerator SlideOut()
    {
        // Prevent the user from interacting
        m_RootGroup.interactable = false;
        m_ButtonSpinAnimation.Stop();

        // Perform the animation
        yield return(Routine.Combine(
                         m_Root.AnchorPosTo(-m_SlideDistance, m_SlideOutSettings, Axis.Y), // Slide back to our original position
                         m_RootGroup.FadeTo(0f, m_SlideOutSettings.Time)                   // Fade out
                         ));

        // Deactivate the menu
        m_RootGroup.gameObject.SetActive(false);
    }
예제 #4
0
    private IEnumerator SpinOut()
    {
        // Prevent the user from interacting
        m_RootGroup.interactable = false;
        m_ButtonSpinAnimation.Stop();

        // Perform the animation
        yield return(Routine.Combine(
                         m_Root.ScaleTo(0, m_SpinOutSettings, Axis.XY),                                                  // Scale to 0
                         m_Root.RotateTo(-360f * m_SpinCount, m_SpinOutSettings, Axis.Z, Space.Self, AngleMode.Absolute) // Spin in reverse
                         ));

        // Deactivate the menu
        m_RootGroup.gameObject.SetActive(false);
    }
예제 #5
0
    // This animates the menu to the Closed state
    private IEnumerator ScaleOut()
    {
        // Prevent the user from interacting
        m_RootGroup.interactable = false;
        m_ButtonSpinAnimation.Stop();

        // Perform the animation
        yield return(Routine.Combine(
                         m_Root.ScaleTo(m_StartingScale, m_ScaleDownSettings, Axis.XY), // Scale back to our original scale
                         m_RootGroup.FadeTo(0, m_ScaleDownSettings.Time)                // Fade out
                         ));

        // Deactivate the menu
        m_RootGroup.gameObject.SetActive(false);
    }
예제 #6
0
    private IEnumerator SwapTo(float inXAlign)
    {
        RectTransform rect = (RectTransform)transform;

        yield return(Routine.Combine(

                         // Set the pivot to the left or right to ensure scaling works how we expect
                         rect.PivotTo(inXAlign, 0.5f, Axis.X).Ease(Curve.QuartOut),

                         // Set the anchor on the x axis to the left or right
                         rect.AnchorTo(new Vector2(inXAlign, 0), 0.5f, Axis.X).Ease(Curve.QuartOut),

                         // Just for fun, let's also change the size of the panel
                         rect.SizeDeltaTo(300 - 100 * inXAlign, 0.5f, Axis.X).Ease(Curve.QuartOut)
                         ));
    }
예제 #7
0
        private IEnumerator UpdateOnePhysics(Transform inTransform)
        {
            while (true)
            {
                yield return(inTransform.MoveTo(inTransform.localPosition.x + 5, 2f, Axis.X, Space.Self).Wave(Wave.Function.Sin, 1).Loop(2));

                yield return(Routine.Combine(
                                 Routine.Combine(
                                     Routine.Yield(CombinedThing()),
                                     Routine.Yield(Routine.WaitForEndOfFrame())
                                     ),
                                 Routine.Yield(Routine.WaitForEndOfFrame())
                                 ));

                yield return(2);
            }
        }
예제 #8
0
        private IEnumerator ShowImpl(float inDelay)
        {
            SetInputState(false);

            if (inDelay > 0)
            {
                yield return(inDelay);
            }

            InvokeOnShow(TransitionType.Animated);
            yield return(Routine.Inline(Routine.Combine(
                                            TransitionToShow(),
                                            SubAnimatorTransition(true)
                                            )));

            SetInputState(true);
            InvokeOnShowComplete(TransitionType.Animated);
        }
예제 #9
0
        private IEnumerator SubAnimatorTransition(bool inbOn)
        {
            if (m_PanelAnimators == null || m_PanelAnimators.Length == 0)
            {
                return(null);
            }

            if (m_PanelAnimators.Length == 1)
            {
                return(m_PanelAnimators[0].TransitionTo(inbOn));
            }

            IEnumerator[] children = new IEnumerator[m_PanelAnimators.Length];
            for (int i = 0; i < m_PanelAnimators.Length; ++i)
            {
                children[i] = Routine.Inline(m_PanelAnimators[i].TransitionTo(inbOn));
            }
            return(Routine.Inline(Routine.Combine(children)));
        }
예제 #10
0
    private IEnumerator SlideIn()
    {
        // Set our initial state
        m_RootGroup.gameObject.SetActive(true);

        m_Root.SetAnchorPos(-m_SlideDistance, Axis.Y);
        m_Root.SetScale(1, Axis.XY);
        m_Root.SetRotation(0, Axis.Z);

        m_RootGroup.alpha        = 0;
        m_RootGroup.interactable = false;

        // Perform the animation
        yield return(Routine.Combine(
                         m_Root.AnchorPosTo(0, m_SlideInSettings, Axis.Y), // Move our anchoredPosition to 0
                         m_RootGroup.FadeTo(1f, m_SlideInSettings.Time)    // Fade in
                         ));

        // Allow the user to interact
        m_RootGroup.interactable = true;
        m_ButtonSpinAnimation.Replace(this, ButtonCallToAction());
    }
예제 #11
0
    private IEnumerator SpinIn()
    {
        // Set our initial state
        m_RootGroup.gameObject.SetActive(true);

        m_Root.SetAnchorPos(0, Axis.XY);
        m_Root.SetScale(0, Axis.XY);
        m_Root.SetRotation(0, Axis.Z);

        m_RootGroup.alpha        = 1;
        m_RootGroup.interactable = false;

        // Perform the animation
        yield return(Routine.Combine(
                         m_Root.ScaleTo(1, m_SpinInSettings, Axis.XY),                                                // Scale to 1
                         m_Root.RotateTo(360 * m_SpinCount, m_SpinInSettings, Axis.Z, Space.Self, AngleMode.Absolute) // Spin multiple times
                         ));

        // Allow the user to interact
        m_RootGroup.interactable = true;
        m_ButtonSpinAnimation.Replace(this, ButtonCallToAction());
    }
예제 #12
0
    // This animates the menu to the Open state
    private IEnumerator ScaleIn()
    {
        // Set our initial state
        m_Root.gameObject.SetActive(true);

        m_Root.SetAnchorPos(0, Axis.XY);
        m_Root.SetScale(m_StartingScale, Axis.XY);
        m_Root.SetRotation(0, Axis.Z);

        m_RootGroup.alpha        = 0;
        m_RootGroup.interactable = false;

        // Perform the animation
        yield return(Routine.Combine(
                         m_Root.ScaleTo(1, m_ScaleUpSettings, Axis.XY), // Scale to 1
                         m_RootGroup.FadeTo(1, m_ScaleUpSettings.Time)  // Fade in
                         ));

        // Allow the user to interact
        m_RootGroup.interactable = true;
        m_ButtonSpinAnimation.Replace(this, ButtonCallToAction());
    }
예제 #13
0
        private IEnumerator HideImpl(float inDelay)
        {
            SetInputState(false);

            if (inDelay > 0)
            {
                yield return(inDelay);
            }

            InvokeOnHide(TransitionType.Animated);
            yield return(Routine.Inline(Routine.Combine(
                                            TransitionToHide(),
                                            SubAnimatorTransition(false)
                                            )));

            if (m_RootTransform)
            {
                m_RootTransform.gameObject.SetActive(false);
            }

            InvokeOnHideComplete(TransitionType.Animated);
        }
예제 #14
0
    private IEnumerator FadeIn()
    {
        // Set our initial state
        m_RootGroup.gameObject.SetActive(true);

        m_Root.SetAnchorPos(0, Axis.Y);
        m_Root.SetScale(1, Axis.XY);
        m_Root.SetRotation(0, Axis.Z);

        m_RootGroup.alpha        = 0;
        m_RootGroup.interactable = false;

        // Perform the animation
        yield return(Routine.Combine(
                         m_RootGroup.FadeTo(1f, m_FadeSettings)
                         ));

        // yielding a Routine.Combine with one item
        // is exactly the same as yielding that item by itself

        // Allow the user to interact
        m_RootGroup.interactable = true;
        m_ButtonSpinAnimation.Replace(this, ButtonCallToAction());
    }
예제 #15
0
        /// <summary>
        /// Performs an ordered sequence of actions.
        /// </summary>
        public IEnumerator PerformActions(RSActionData[] inActions)
        {
            using (new SharedRef <ExecutionScope>(this))
            {
                if (inActions == null || inActions.Length <= 0)
                {
                    yield break;
                }

                for (int i = 0; i < inActions.Length; ++i)
                {
                    if (!inActions[i].Enabled)
                    {
                        continue;
                    }

                    var ret = PerformAction(inActions[i]);

                    if (ret.Set != null)
                    {
                        PooledList <IEnumerator> waits = null;

                        foreach (var val in ret.Set)
                        {
                            switch (val.Type)
                            {
                            case ActionResultType.Iterator:
                            {
                                if (waits == null)
                                {
                                    waits = PooledList <IEnumerator> .Alloc();
                                }

                                waits.Add((IEnumerator)val.Value);
                                break;
                            }
                            }
                        }

                        if (waits != null && waits.Count > 0)
                        {
                            IEnumerator combinedWait = Routine.Combine(waits);
                            waits.Dispose();
                            waits = null;

                            yield return(combinedWait);
                        }
                    }
                    else
                    {
                        switch (ret.Single.Type)
                        {
                        case ActionResultType.Iterator:
                            yield return(ret.Single.Value);

                            break;
                        }
                    }
                }
            }
        }