예제 #1
0
 public override void Do(UITransitionContext context, Action <string, UITransitionContext> onComplete)
 {
     if (!Validate(context.from))
     {
         return;
     }
     StartCoroutine(Execute(context, onComplete));
 }
예제 #2
0
        private void Show(RouterItem routerItem)
        {
            if (routerItem.panel == null)
            {
                Debug.LogError("Can not transition to null view.");
                return;
            }

            if (topPanel != null && topPanel.Equals(routerItem.panel) && routerItem.mode == RouterHistoryMode.pushState)
            {
                RefreshCurrentView();
                CheckQueue();
                return;
            }

            if (IsPanelInStack(routerItem.panel))
            {
                Debug.LogError("Component already in stack, can not spawn copies of component.");
                return;
            }

            if (routerItem.config == null)
            {
                Debug.LogError("Transition config must be defined to display component.");
                return;
            }

            IUITransitable currentPanel = topPanel;
            UITransition   transition   = Registry.transitionRegistry[routerItem.config.type];

            if (transition == null)
            {
                Debug.LogError("No transition with id: " + routerItem.config.type.ToString() + " found.");
                return;
            }

            transitionInProcess = true;
            UITransitionContext context = new UITransitionContext(routerItem.config, currentPanel, routerItem.panel);

            transition.Do(context, (string error, UITransitionContext inContext) => {
                transitionInProcess = false;
                if (error != null)
                {
                    Debug.LogError(error);
                    return;
                }

                if (inContext.from != null && routerItem.mode == RouterHistoryMode.replaceState)
                {
                    viewStack.RemoveFirst();
                }

                viewStack.AddFirst(routerItem.panel);

                routerItem.panel.OnUITransitionComplete();
                CheckQueue();
            });
        }
예제 #3
0
        protected override void PreExecute(UITransitionContext context, ScreenOffset from, ScreenOffset to, ref AnimationContext animContext)
        {
            Utils.CalcPanelNDCRect(context.from.rect, from.offsetX, from.offsetY, ref animContext.rectFrom);
            Utils.CalcPanelNDCRect(context.from.rect, to.offsetX, to.offsetY, ref animContext.rectTo);
            EnableComponent(context.to);

            if (context.from != null && context.from.rect != null)
            {
                Utils.SetInteractable(context.from.rect.transform, false);
                context.from.OnUIDisable();
            }
        }
예제 #4
0
        protected override void PostExecute(UITransitionContext context, ref AnimationContext animContext, bool hideSourcePanel)
        {
            RectTransform rc = context.from.rect;

            rc.offsetMin = animContext.rectTo.GetMinExtents();
            rc.offsetMax = animContext.rectTo.GetMaxExtents();

            if (context.from != null && context.from.rect != null)
            {
                context.from.rect.gameObject.SetActive(false);
                context.from.OnUIHide();
            }
        }
예제 #5
0
        protected virtual void ExecuteStep(UITransitionContext context, ref AnimationContext animContext)
        {
            RectTransform rc = context.to.rect;

            float t = animContext.elapsedTime / context.config.duration;

            if (t > 1.0f)
            {
                t = 1.0f;
            }

            rc.offsetMin = animContext.rectFrom.GetMinExtents() * (1.0f - t) + animContext.rectTo.GetMinExtents() * t;
            rc.offsetMax = animContext.rectFrom.GetMaxExtents() * (1.0f - t) + animContext.rectTo.GetMaxExtents() * t;

            animContext.elapsedTime += Time.deltaTime;
        }
예제 #6
0
        private IEnumerator Execute(UITransitionContext context, Action <string, UITransitionContext> onComplete)
        {
            AnimationContext animContext = new AnimationContext();
            Config           config      = (Config)context.config;

            PreExecute(context,
                       new ScreenOffset(Utils.OffsetCalcMode.Centered, Utils.OffsetCalcMode.Centered),
                       CalcScreenOffset(config.direction),
                       ref animContext);
            while (animContext.elapsedTime < context.config.duration)
            {
                ExecuteStep(context, ref animContext);
                yield return(null);
            }
            PostExecute(context, ref animContext, false);
            onComplete.Invoke(null, context);

            yield break;
        }
예제 #7
0
        public override void HideTopmost(UITransitionConfig config)
        {
            if (viewStack.Count <= 0)
            {
                Debug.LogError("No Component");
                return;
            }

            if (config == null)
            {
                Debug.LogError("config null");
                return;
            }

            IUITransitable currentPanel = topPanel;
            IUITransitable toPanel      = viewStack.Count > 1 ? viewStack.Skip(1).First() : null;
            UITransition   transition   = Registry.transitionRegistry[config.type];

            if (transition == null)
            {
                Debug.LogError("No transition found to hide view.");
                return;
            }

            transitionInProcess = true;
            UITransitionContext context = new UITransitionContext(config, currentPanel, toPanel);

            transition.Do(context, (string error, UITransitionContext inContext) => {
                transitionInProcess = false;
                if (error != null)
                {
                    Debug.LogError(error);
                    return;
                }

                viewStack.RemoveFirst();
                CheckQueue();
            });
        }
예제 #8
0
        protected virtual void PreExecute(UITransitionContext context, ScreenOffset from, ScreenOffset to, ref AnimationContext animContext)
        {
            Utils.CalcPanelNDCRect(context.to.rect,
                                   from.offsetX,
                                   from.offsetY,
                                   ref animContext.rectFrom);
            Utils.CalcPanelNDCRect(context.to.rect,
                                   to.offsetX,
                                   to.offsetY,
                                   ref animContext.rectTo);
            EnableComponent(context.to);

            RectTransform rc = context.to.rect;

            rc.offsetMin = new Vector2(animContext.rectFrom.xMin, animContext.rectFrom.yMin);
            rc.offsetMax = new Vector2(animContext.rectFrom.xMax, animContext.rectFrom.yMax);
            rc.SetAsLastSibling();

            if (context.from != null && context.from.rect != null)
            {
                Utils.SetInteractable(context.from.rect.transform, false);
                context.from.OnUIDisable();
            }
        }
예제 #9
0
 public virtual void Do(UITransitionContext context, Action <string, UITransitionContext> onComplete)
 {
 }