public void VerifyEvents()
        {
            ViewSystemVisualEditor.RefreshMethodDatabase();
            RefreshEventDatas();
            eventDataNeedToFix.Clear();
            foreach (var vpi in allEventDatas)
            {
                foreach (var item in vpi.eventDatas)
                {
                    var t = MacacaGames.Utility.GetType(item.scriptName);
                    if (t == null)
                    {
                        ViewSystemLog.LogError(item.targetComponentType + " still not fixed cannot be found, will ignore while verify property");
                        eventDataNeedToFix.Add(item);
                        continue;
                    }

                    if (t.GetMethod(item.methodName, bindingFlags) == null)
                    {
                        ViewSystemLog.LogError($"{item.methodName} in {item.scriptName} cannot be found");
                        eventDataNeedToFix.Add(item);
                        continue;
                    }
                }
            }
            if (eventDataNeedToFix.Count > 0)
            {
                if (EditorUtility.DisplayDialog(
                        "Something goes wrong!",
                        "There are some event data is missing, do you want to open fixer window",
                        "Yes, Please",
                        "Not now"))
                {
                    var window = ScriptableObject.CreateInstance <EventFixerWindow>();
                    window.SetData(eventDataNeedToFix, ViewSystemVisualEditor.classMethodInfo, () =>
                    {
                        //Make sure SetDirty
                        EditorUtility.SetDirty(saveData);
                    });
                    window.ShowUtility();
                }
            }
            else
            {
                ViewSystemLog.Log("Great, all events looks good!");
            }
        }
        public void VerifyPagesAndStates()
        {
            if (editor == null)
            {
                ViewSystemLog.LogError("Cannot verify save data, is editor init correctlly?");
                return;
            }

            if (saveData == null)
            {
                ViewSystemLog.LogError("Cannot verify save data, is editor init correctlly?");
                return;
            }
            string result     = "";
            var    viewStates = saveData.viewStates.Select(m => m.viewState).ToList();
            var    viewPages  = saveData.viewPages.Select(m => m.viewPage).ToList();

            foreach (var states in viewStates)
            {
                foreach (var item in states.viewPageItems)
                {
                    if (item.viewElement == null)
                    {
                        result += $"One ViewElement in State : [{states.name}] is null.";
                    }
                }
            }
            foreach (var pages in viewPages)
            {
                foreach (var item in pages.viewPageItems)
                {
                    if (item.viewElement == null)
                    {
                        result += $"One ViewElement in Page : [{pages.name}] is null.";
                    }
                }
            }
            if (!string.IsNullOrEmpty(result))
            {
                ViewSystemLog.LogError(result);
            }
            else
            {
                ViewSystemLog.Log("Great, all pages and states looks good!");
            }
        }
        public void VerifyGameObject(VerifyTarget verifyTarget = VerifyTarget.All)
        {
            if (editor == null)
            {
                ViewSystemLog.LogError("Cannot verify save data, is editor init correctlly?");
                return;
            }

            if (saveData == null)
            {
                ViewSystemLog.LogError("Cannot verify save data, is editor init correctlly?");
                return;
            }

            gameObjectCannotBeFound.Clear();

            var overrideDatasInPages  = saveData.viewPages.Select(m => m.viewPage);
            var overrideDatasInStates = saveData.viewStates.Select(m => m.viewState);

            foreach (var viewPage in overrideDatasInPages)
            {
                foreach (var viewPageItem in viewPage.viewPageItems)
                {
                    List <ViewSystemComponentData> verifyTargets = new List <ViewSystemComponentData>();

                    if (verifyTarget == VerifyTarget.All || verifyTarget == VerifyTarget.Override)
                    {
                        verifyTargets.AddRange(viewPageItem.overrideDatas.Cast <ViewSystemComponentData>());
                    }

                    if (verifyTarget == VerifyTarget.All || verifyTarget == VerifyTarget.Event)
                    {
                        verifyTargets.AddRange(viewPageItem.eventDatas.Cast <ViewSystemComponentData>());
                    }
                    if (viewPageItem.viewElement == null)
                    {
                        ViewSystemLog.LogError("One or more viewElement is null, verify Page and State first.");
                        return;
                    }
                    foreach (var verifyData in verifyTargets)
                    {
                        var transform = viewPageItem.viewElement.transform.Find(verifyData.targetTransformPath);
                        if (transform == null)
                        {
                            gameObjectCannotBeFound.Add(
                                new ViewSystemGameObjectMissingData
                            {
                                isViewState         = false,
                                viewElement         = viewPageItem.viewElement,
                                stateOrPageName     = viewPage.name,
                                viewSystemComponent = verifyData
                            });
                        }
                    }
                }
            }

            foreach (var viewState in overrideDatasInStates)
            {
                foreach (var viewPageItem in viewState.viewPageItems)
                {
                    List <ViewSystemComponentData> verifyTargets = new List <ViewSystemComponentData>();

                    if (verifyTarget == VerifyTarget.All || verifyTarget == VerifyTarget.Override)
                    {
                        verifyTargets.AddRange(viewPageItem.overrideDatas.Cast <ViewSystemComponentData>());
                    }

                    if (verifyTarget == VerifyTarget.All || verifyTarget == VerifyTarget.Event)
                    {
                        verifyTargets.AddRange(viewPageItem.eventDatas.Cast <ViewSystemComponentData>());
                    }

                    foreach (var verifyData in verifyTargets)
                    {
                        var transform = viewPageItem.viewElement.transform.Find(verifyData.targetTransformPath);
                        if (transform == null)
                        {
                            gameObjectCannotBeFound.Add(
                                new ViewSystemGameObjectMissingData
                            {
                                isViewState         = true,
                                viewElement         = viewPageItem.viewElement,
                                stateOrPageName     = viewState.name,
                                viewSystemComponent = verifyData
                            });
                        }
                    }
                }
            }

            if (gameObjectCannotBeFound.Count > 0)
            {
                if (EditorUtility.DisplayDialog(
                        "Something goes wrong!",
                        "There are some GameObject is missing, do you want to open fixer window",
                        "Yes, Please",
                        "Not now"))
                {
                    var window = ScriptableObject.CreateInstance <GameObjectFixerWindow>();
                    window.SetData(gameObjectCannotBeFound, saveData, () =>
                    {
                        //Make sure SetDirty
                        EditorUtility.SetDirty(saveData);
                    });
                    window.ShowUtility();
                }
            }
            else
            {
                ViewSystemLog.Log("GameObject looks good.");
            }
        }
        public override void OnDrawScrollArea()
        {
            GUILayout.Label(new GUIContent($"Event fixer will replace all saved EventData please be careful", EditorGUIUtility.FindTexture("console.erroricon")));
            foreach (var item in needFixEventData)
            {
                using (var horizon = new EditorGUILayout.HorizontalScope("box"))
                {
                    item.fix = EditorGUILayout.ToggleLeft(GUIContent.none, item.fix, GUILayout.Width(20));
                    using (var vertical = new EditorGUILayout.VerticalScope())
                    {
                        using (var horizon2 = new EditorGUILayout.HorizontalScope())
                        {
                            GUILayout.Label($"Method : [{item.originalMethodName}] in Script : [{item.originalScriptName}]");

                            using (var disable = new EditorGUI.DisabledGroupScope(!classMethodInfo.ContainsKey(item.originalScriptName)))
                            {
                                if (GUILayout.Button("Apply Origin Data"))
                                {
                                    item.modifyScriptName = item.originalScriptName;
                                    item.modifyMethodName = item.originalMethodName;
                                }
                            }
                        }
                        int currentSelectClass = string.IsNullOrEmpty(item.modifyScriptName) ? 0 : classMethodInfo.Values.ToList().IndexOf(classMethodInfo[item.modifyScriptName]);
                        using (var check = new EditorGUI.ChangeCheckScope())
                        {
                            currentSelectClass = EditorGUILayout.Popup("Event Script", currentSelectClass, classMethodInfo.Select(m => m.Key).ToArray());
                            if (check.changed)
                            {
                                ViewSystemLog.Log(currentSelectClass);
                                if (currentSelectClass != 0)
                                {
                                    var c = classMethodInfo.ElementAt(currentSelectClass);
                                    item.modifyScriptName = c.Key;
                                    item.modifyMethodName = "";
                                }
                                else
                                {
                                    item.modifyScriptName = "";
                                    item.modifyMethodName = "";
                                }
                            }
                        }
                        if (currentSelectClass != 0)
                        {
                            using (var check = new EditorGUI.ChangeCheckScope())
                            {
                                using (var horizon2 = new EditorGUILayout.HorizontalScope())
                                {
                                    var c       = classMethodInfo.ElementAt(currentSelectClass).Value;
                                    var current = c.SingleOrDefault(m => m.name == item.modifyMethodName);
                                    CMEditorLayout.GroupedPopupField(item.GetHashCode(), new GUIContent("Event Method"), c, current,
                                                                     (select) =>
                                    {
                                        item.modifyMethodName = select.name;
                                    }
                                                                     );
                                }
                            }
                        }
                    }
                }
            }
        }
        public void VerifyProperty(VerifyTarget verifyTarget)
        {
            propertyCannotBeFound.Clear();
            IEnumerable <ViewSystemComponentData> targetVerifyDatas = null;

            //Data may changed by Component fixer so refresh again.
            if (verifyTarget == VerifyTarget.Override)
            {
                RefreshOverrideDatas();
                targetVerifyDatas = allOverrideDatas.SelectMany(m => m.overrideDatas).Cast <ViewSystemComponentData>();
            }
            if (verifyTarget == VerifyTarget.Event)
            {
                RefreshEventDatas();
                targetVerifyDatas = allEventDatas.SelectMany(m => m.eventDatas).Cast <ViewSystemComponentData>();
            }

            foreach (var item in targetVerifyDatas)
            {
                var t = MacacaGames.Utility.GetType(item.targetComponentType);
                if (t == null)
                {
                    ViewSystemLog.LogError(item.targetComponentType + " still not fixed cannot be found, will ignore while verify property");
                    continue;
                }
                var propertyName = item.targetPropertyName;
                if (t.ToString().Contains("UnityEngine."))
                {
                    propertyName = ViewSystemUtilitys.ParseUnityEngineProperty(item.targetPropertyName);
                }

                if (t.GetField(item.targetPropertyName, bindingFlags) == null && t.GetProperty(propertyName, bindingFlags) == null)
                {
                    ViewSystemLog.LogError($"{item.targetPropertyName} in {item.targetComponentType} cannot be found");
                    if (propertyCannotBeFound.Count(m => m == item.targetComponentType + "," + item.targetPropertyName) == 0)
                    {
                        propertyCannotBeFound.Add(item.targetComponentType + "," + item.targetPropertyName);
                    }
                }
            }

            if (propertyCannotBeFound.Count > 0)
            {
                if (EditorUtility.DisplayDialog(
                        "Something goes wrong!",
                        "There are some override property is missing, do you want to open fixer window",
                        "Yes, Please",
                        "Not now"))
                {
                    var window = ScriptableObject.CreateInstance <PropertyFixerWindow>();
                    window.SetData(propertyCannotBeFound, targetVerifyDatas, saveData, () =>
                    {
                        //Make sure SetDirty
                        EditorUtility.SetDirty(saveData);
                        if (verifyTarget == VerifyTarget.Event)
                        {
                            VerifyEvents();
                        }
                    });
                    window.ShowUtility();
                }
            }
            else
            {
                ViewSystemLog.Log("Great, everying looks good!");
            }
        }
        public void VerifyComponent(VerifyTarget verifyTarget)
        {
            if (editor == null)
            {
                ViewSystemLog.LogError("Cannot verify save data, is editor init correctlly?");
                return;
            }

            if (saveData == null)
            {
                ViewSystemLog.LogError("Cannot verify save data, is editor init correctlly?");
                return;
            }
            typeNameCannotBeFound.Clear();
            if (verifyTarget == VerifyTarget.Event)
            {
                RefreshEventDatas();
                foreach (var vpi in allEventDatas)
                {
                    foreach (var item in vpi.eventDatas)
                    {
                        var t = MacacaGames.Utility.GetType(item.targetComponentType);
                        if (t == null)
                        {
                            ViewSystemLog.LogError(item.targetComponentType + "  cannot be found");
                            typeNameCannotBeFound.Add(item.targetComponentType);
                        }
                    }
                }
            }
            if (verifyTarget == VerifyTarget.Override)
            {
                RefreshOverrideDatas();
                foreach (var vpi in allOverrideDatas)
                {
                    foreach (var item in vpi.overrideDatas)
                    {
                        var t = MacacaGames.Utility.GetType(item.targetComponentType);
                        if (t == null)
                        {
                            ViewSystemLog.LogError(item.targetComponentType + "  cannot be found");
                            typeNameCannotBeFound.Add(item.targetComponentType);
                        }
                    }
                }
            }

            if (typeNameCannotBeFound.Count > 0)
            {
                if (EditorUtility.DisplayDialog(
                        "Something goes wrong!",
                        "There are some override component is missing, do you want to open fixer window",
                        "Yes, Please",
                        "Not now"))
                {
                    List <ViewSystemComponentData> componentDatas;
                    if (verifyTarget == VerifyTarget.Override)
                    {
                        componentDatas = allOverrideDatas.Cast <ViewSystemComponentData>().ToList();
                    }
                    else
                    {
                        componentDatas = allEventDatas.Cast <ViewSystemComponentData>().ToList();
                    }
                    var window = ScriptableObject.CreateInstance <ComponentFixerWindow>();
                    window.SetData(typeNameCannotBeFound, componentDatas, () =>
                    {
                        //Make sure SetDirty
                        EditorUtility.SetDirty(saveData);
                        VerifyProperty(verifyTarget);
                    });
                    window.ShowUtility();
                }
            }
            else
            {
                ViewSystemLog.Log("Components looks good, let's check properties.");
                VerifyProperty(verifyTarget);
            }
        }
Exemplo n.º 7
0
        public override IEnumerator LeaveOverlayViewPageBase(ViewSystemUtilitys.OverlayPageStatus overlayPageState, float tweenTimeIfNeed, Action OnComplete, bool ignoreTransition = false, bool ignoreTimeScale = false, bool waitForShowFinish = false)
        {
            if (waitForShowFinish && overlayPageState.transition == ViewSystemUtilitys.OverlayPageStatus.Transition.Show)
            {
                ViewSystemLog.Log("Leave Overlay Page wait for pervious page");
                yield return(new WaitUntil(() => !overlayPageState.IsTransition));
            }

            var currentVe = currentViewPage.viewPageItems.Select(m => m.runtimeViewElement);
            var currentVs = currentViewState.viewPageItems.Select(m => m.runtimeViewElement);

            var finishTime = ViewSystemUtilitys.CalculateOnLeaveDuration(overlayPageState.viewPage.viewPageItems.Select(m => m.runtimeViewElement));

            overlayPageState.transition = ViewSystemUtilitys.OverlayPageStatus.Transition.Leave;

            List <ViewPageItem> viewPageItems = new List <ViewPageItem>();

            viewPageItems.AddRange(overlayPageState.viewPage.viewPageItems);
            if (overlayPageState.viewState != null)
            {
                viewPageItems.AddRange(overlayPageState.viewState.viewPageItems);
            }

            foreach (var item in viewPageItems)
            {
                if (item.runtimeViewElement == null)
                {
                    ViewSystemLog.LogWarning($"ViewElement : {item.viewElement.name} is null in runtime.");
                    continue;
                }
                // Unique 的 ViewElement 另外處理借用問題
                // 暫時不處理 多個 overlay 之間借用的問題!!!
                if (item.runtimeViewElement.IsUnique == true && IsPageTransition == false)
                {
                    if (currentVe.Contains(item.runtimeViewElement))
                    {
                        //準備自動離場的 ViewElement 目前的頁面正在使用中 所以不要對他操作
                        try
                        {
                            var vpi = currentViewPage.viewPageItems.FirstOrDefault(m => ReferenceEquals(m.runtimeViewElement, item.runtimeViewElement));

                            var transformData = vpi.GetCurrentViewElementTransform(breakPointsStatus);
                            if (!string.IsNullOrEmpty(transformData.parentPath))
                            {
                                vpi.runtimeParent = transformCache.Find(transformData.parentPath);
                            }
                            else
                            {
                                vpi.runtimeParent = currentViewPage.runtimePageRoot;
                            }

                            item.runtimeViewElement.ChangePage(true, vpi.runtimeParent, transformData, item.sortingOrder, tweenTimeIfNeed, 0);
                            ViewSystemLog.LogWarning("ViewElement : " + item.viewElement.name + "Try to back to origin Transfrom parent : " + vpi.runtimeParent.name);
                        }
                        catch { }
                        continue;
                    }
                    if (currentVs.Contains(item.runtimeViewElement))
                    {
                        //準備自動離場的 ViewElement 目前的頁面正在使用中 所以不要對他操作
                        try
                        {
                            var vpi = currentViewState.viewPageItems.FirstOrDefault(m => ReferenceEquals(m.runtimeViewElement, item.runtimeViewElement));

                            var transformData = vpi.GetCurrentViewElementTransform(breakPointsStatus);
                            if (!string.IsNullOrEmpty(transformData.parentPath))
                            {
                                vpi.runtimeParent = transformCache.Find(transformData.parentPath);
                            }
                            else
                            {
                                vpi.runtimeParent = currentViewPage.runtimePageRoot;
                            }
                            item.runtimeViewElement.ChangePage(true, vpi.runtimeParent, transformData, item.sortingOrder, tweenTimeIfNeed, 0);
                            ViewSystemLog.LogWarning("ViewElement : " + item.runtimeViewElement.name + "Try to back to origin Transfrom parent : " + vpi.runtimeParent.name);
                        }
                        catch { }
                        continue;
                    }
                }

                // lastOverlayPageItemDelayOutTimes.TryGetValue(item.runtimeViewElement.name, out float delayOut);
                item.runtimeViewElement.ChangePage(false, null, null, item.sortingOrder, 0, 0, ignoreTransition);
            }

            yield return(runtimePool.RecoveryQueuedViewElement());

            //Get Back the Navigation to CurrentPage
            SetNavigationTarget(currentViewPage);
            InvokeOnOverlayPageLeave(this, new ViewPageEventArgs(overlayPageState.viewPage, null));

            if (ignoreTimeScale)
            {
                yield return(Yielders.GetWaitForSecondsRealtime(finishTime));
            }
            else
            {
                yield return(Yielders.GetWaitForSeconds(finishTime));
            }

            overlayPageState.IsTransition = false;

            string OverlayPageStateKey = GetOverlayStateKey(overlayPageState.viewPage);

            overlayPageStatusDict.Remove(OverlayPageStateKey);

            OnComplete?.Invoke();
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
        void PrewarmInjection()
        {
            var viewElementsInStates = viewStates.Values.Select(m => m.viewPageItems).SelectMany(ma => ma).Select(m => m.viewElement);
            var viewElementsInPages  = viewPages.Values.Select(m => m.viewPageItems).SelectMany(ma => ma).Select(m => m.viewElement);

            foreach (var item in viewElementsInStates)
            {
                if (item == null)
                {
                    ViewSystemLog.Log("I'm null!!!");
                    continue;
                }
                if (!item.IsUnique)
                {
                    continue;
                }

                var r = runtimePool.PrewarmUniqueViewElement(item);
                if (r != null)
                {
                    foreach (var i in r.GetComponents <IViewElementInjectable>())
                    {
                        var c = (Component)i;
                        var t = c.GetType();
                        if (!InjectionDictionary.ContainsKey(t))
                        {
                            InjectionDictionary.Add(t, c);
                        }
                        else
                        {
                            ViewSystemLog.LogWarning("Type " + t + " has been injected");
                            continue;
                        }
                    }
                }
            }

            foreach (var item in viewElementsInPages)
            {
                if (item == null)
                {
                    ViewSystemLog.Log("I'm null!!!");
                    continue;
                }
                if (!item.IsUnique)
                {
                    continue;
                }

                var r = runtimePool.PrewarmUniqueViewElement(item);
                if (r != null)
                {
                    foreach (var i in r.GetComponents <IViewElementInjectable>())
                    {
                        var c = (Component)i;
                        var t = c.GetType();
                        if (!InjectionDictionary.ContainsKey(t))
                        {
                            InjectionDictionary.Add(t, c);
                        }
                        else
                        {
                            ViewSystemLog.LogWarning("Type " + t + " has been injected");
                            continue;
                        }
                    }
                }
            }
        }