Example #1
0
    private void ShowViewImmediate(IAnimatedView view)
    {
        // this is a SUPER special case where we want to pop the view on immediately with no animation
        currentView = viewStack.Peek();         // this should be the share choice dialog
        currentView.LeavingPercent(1.0f);
        currentView.OutOfView(view);
        SetViewActive(currentView, false);
        viewStack.Pop();         // pop off the share choice dialog

        currentView = viewStack.Peek();
        viewStack.Push(view);
        SetViewActive(view, true);
        view.EnteringPercent(1.0f);
        view.InView(currentView);
        currentView = view;
    }
Example #2
0
    IEnumerator TransitionView(IAnimatedView oldView, IAnimatedView newView, float crossfadePercent = 0.0f)
    {
        // crossfade delay
        transitionPending = true;
        float startTime      = Time.time;
        float newStartTime   = startTime;
        float newEndTime     = startTime;
        bool  oldViewDone    = true;
        bool  newViewStarted = false;

        if (oldView != null)
        {
            newStartTime = startTime + (1 - crossfadePercent) * oldView.OutTime;
            TriggerViewAnimation(oldView, oldView.OutTrigger);
            oldViewDone = false;
            oldView.LeavingView(newView);
        }

        if (newView != null)
        {
            newEndTime = newStartTime + newView.InTime;
        }

        while (true)
        {
            float ellapsed = Time.time - startTime;

            if (!oldViewDone)
            {
                float p = Mathf.Clamp01(ellapsed / oldView.OutTime);

                oldView.LeavingPercent(p);

                if (p == 1.0f)
                {
                    oldView.OutOfView(newView);
                    SetViewActive(oldView, false);
                    oldViewDone = true;
                }
            }

            if (!newViewStarted && Time.time >= newStartTime)
            {
                SetViewActive(newView, true);
                newView.EnteringView(oldView);
                TriggerViewAnimation(newView, newView.InTrigger);
                newViewStarted = true;
                currentView    = newView;
            }

            if (newViewStarted)
            {
                float p = Mathf.Clamp01((Time.time - newStartTime) / newView.InTime);
                newView.EnteringPercent(p);
                if (p == 1.0f)
                {
                    newView.InView(oldView);
                    break;
                }
            }

            yield return(null);
        }

        transitionPending = false;

        DumpViewStack();

        if (nextView != null)
        {
            // special case for Back show mode for now...
            if (nextViewShowMode == ShowMode.Back)
            {
                Back();
            }
            else
            {
                ShowView(nextView, nextViewShowMode);
            }
        }
    }