public ViewPageSaveData(Vector2 nodePosition, ViewPage viewPage)
 {
     this.nodePosition = nodePosition;
     this.viewPage     = viewPage;
 }
Esempio n. 2
0
 public static string GetPageRootName(ViewPage viewPage)
 {
     return("Page_" + (viewPage.viewPageType == ViewPage.ViewPageType.FullPage ? "FullPage" : viewPage.name));
 }
Esempio n. 3
0
 public virtual IEnumerator ShowOverlayViewPageBase(ViewPage vp, bool RePlayOnShowWhileSamePage, Action OnStart, Action OnChanged, Action OnComplete, bool ignoreTimeScale = false)
 {
     //Empty implement will override in child class
     yield return(null);
 }
Esempio n. 4
0
 public T GetViewPageElementComponentByName <T>(ViewPage viewPage, string viewPageItemName) where T : Component
 {
     return(GetViewPageElementByName(viewPage, viewPageItemName).GetComponent <T>());
 }
Esempio n. 5
0
 //Get ViewElement in viewPage
 public ViewElement GetViewPageElementByName(ViewPage viewPage, string viewPageItemName)
 {
     return(viewPage.viewPageItems.SingleOrDefault((_) => _.displayName == viewPageItemName).runtimeViewElement);
 }
Esempio n. 6
0
        public override IEnumerator ShowOverlayViewPageBase(ViewPage vp, bool RePlayOnShowWhileSamePage, Action OnStart, Action OnChanged, Action OnComplete, bool ignoreTimeScale)
        {
            // Debug.Log("ShowOverlayViewPageBase " + vp.name);
            if (vp == null)
            {
                ViewSystemLog.Log("ViewPage is null");
                yield break;
            }
            if (vp.viewPageType != ViewPage.ViewPageType.Overlay)
            {
                ViewSystemLog.LogError("ViewPage " + vp.name + " is not an Overlay page");
                yield break;
            }
            //Prepare runtime page root
            string viewPageRootName = ViewSystemUtilitys.GetPageRootName(vp);
            var    pageWrapper      = ViewSystemUtilitys.CreatePageTransform(viewPageRootName, rootCanvasTransform, vp.canvasSortOrder);

            if (vp.runtimePageRoot == null)
            {
                vp.runtimePageRoot = pageWrapper.rectTransform;
            }
            pageWrapper.safePadding.SetPaddingValue(vp.edgeValues);

            ViewState viewState = null;

            viewStates.TryGetValue(vp.viewState, out viewState);

            List <ViewElement>         viewElementDoesExitsInNextPage = new List <ViewElement>();
            IEnumerable <ViewPageItem> viewItemNextPage    = null;
            IEnumerable <ViewPageItem> viewItemNextState   = null;
            List <ViewPageItem>        viewItemForNextPage = new List <ViewPageItem>();

            string OverlayPageStateKey = GetOverlayStateKey(vp);
            bool   samePage            = false;

            //檢查是否有同 State 的 Overlay 頁面在場上
            if (overlayPageStatusDict.TryGetValue(OverlayPageStateKey, out ViewSystemUtilitys.OverlayPageStatus overlayPageStatus))
            {
                viewItemNextPage = PrepareRuntimeReference(GetAllViewPageItemInViewPage(vp));

                //同 OverlayState 的頁面已經在場上,移除不同的部分,然後顯示新加入的部分
                if (!string.IsNullOrEmpty(vp.viewState))
                {
                    if (overlayPageStatus.viewPage.name != vp.name)
                    {
                        // 同 State 不同 Page 的情況,找到差異的部分
                        foreach (var item in overlayPageStatus.viewPage.viewPageItems)
                        {
                            if (!vp.viewPageItems.Select(m => m.runtimeViewElement).Contains(item.runtimeViewElement))
                            {
                                viewElementDoesExitsInNextPage.Add(item.runtimeViewElement);
                            }
                        }
                        overlayPageStatus.viewPage = vp;
                    }
                }
                else
                {
                    //只有 ViewPage 卻還是進來這裡的話代表頁面還在場上
                    // RePlayOnShowWhileSamePage == false 那就更新數值 所以停掉舊的 Coroutine
                    if (overlayPageStatus.pageChangeCoroutine != null)
                    {
                        StopCoroutine(overlayPageStatus.pageChangeCoroutine);
                    }
                    samePage = true;
                    overlayPageStatus.transition = ViewSystemUtilitys.OverlayPageStatus.Transition.Show;
                }
            }
            else
            {
                //同 OverlayState 的頁面還不在場上 新建一個 Status

                overlayPageStatus            = new ViewSystemUtilitys.OverlayPageStatus();
                overlayPageStatus.viewPage   = vp;
                overlayPageStatus.viewState  = viewState;
                overlayPageStatus.transition = ViewSystemUtilitys.OverlayPageStatus.Transition.Show;
                viewItemNextPage             = PrepareRuntimeReference(GetAllViewPageItemInViewPage(vp));

                // 沒有 viewState 的 Page 不需要處理 viewState 的 runtimeViewElement
                if (!string.IsNullOrEmpty(vp.viewState))
                {
                    // nextViewState = viewStates.SingleOrDefault(m => m.name == vp.viewState);
                    if (viewStates.TryGetValue(vp.viewState, out nextViewState))
                    {
                        viewItemNextState = GetAllViewPageItemInViewState(nextViewState);
                        viewItemNextState = PrepareRuntimeReference(viewItemNextState);
                    }
                }

                overlayPageStatusDict.Add(OverlayPageStateKey, overlayPageStatus);
            }

            OnStart?.Invoke();
            float onShowTime  = ViewSystemUtilitys.CalculateOnShowDuration(viewItemNextPage.Select(m => m.runtimeViewElement));
            float onShowDelay = ViewSystemUtilitys.CalculateDelayInTime(viewItemNextPage);

            //對離場的呼叫改變狀態
            foreach (var item in viewElementDoesExitsInNextPage)
            {
                Debug.LogWarning($"{item.name} not exsit in next page");

                item.ChangePage(false, null, null, 0, 0, 0);
            }

            viewItemForNextPage.AddRange(viewItemNextPage);
            if (viewItemNextState != null)
            {
                viewItemForNextPage.AddRange(viewItemNextState);
            }
            //對進場的呼叫改變狀態
            foreach (var item in viewItemNextPage)
            {
                if (RePlayOnShowWhileSamePage && samePage)
                {
                    item.runtimeViewElement.OnShow();
                    continue;
                }
                //套用複寫值
                item.runtimeViewElement.ApplyOverrides(item.overrideDatas);
                item.runtimeViewElement.ApplyEvent(item.eventDatas);

                var transformData = item.GetCurrentViewElementTransform(breakPointsStatus);

                if (!string.IsNullOrEmpty(transformData.parentPath))
                {
                    item.runtimeParent = transformCache.Find(transformData.parentPath);
                }
                else
                {
                    item.runtimeParent = vp.runtimePageRoot;
                }


                item.runtimeViewElement.ChangePage(true, item.runtimeParent, transformData, item.sortingOrder, item.TweenTime, item.delayIn, reshowIfSamePage: RePlayOnShowWhileSamePage);
            }

            SetNavigationTarget(vp);
            yield return(runtimePool.RecoveryQueuedViewElement());

            //Fire the event
            OnChanged?.Invoke();
            InvokeOnOverlayPageShow(this, new ViewPageEventArgs(vp, null));

            //當所有表演都結束時
            if (ignoreTimeScale)
            {
                yield return(Yielders.GetWaitForSecondsRealtime(onShowTime + onShowDelay));
            }
            else
            {
                yield return(Yielders.GetWaitForSeconds(onShowTime + onShowDelay));
            }

            overlayPageStatus.IsTransition = false;

            OnComplete?.Invoke();
        }