/// <summary>
        /// 获取可用的bridge
        /// </summary>
        /// <param name="parentPanel"></param>
        /// <param name="panelName"></param>
        /// <returns></returns>
        protected Bridge GetBridgeClamp(IUIPanel parentPanel, string panelName, int index)
        {
            Bridge     bridge     = null;
            var        parentName = parentPanel == null ? "" : parentPanel.Name;
            var        mayInfos   = Bridges.FindAll(x => x.outNode == panelName && (x.index == index || index == -1)); //所有可能的
            var        baseInfos  = mayInfos.FindAll(x => x.inNode == parentName);                                     //所有父级名相同的
            BridgeInfo?bridgeInfo = null;

            if (baseInfos.Count > 0)
            {
                bridgeInfo = baseInfos[0];
            }
            else
            {
                var usefulInfos = mayInfos.FindAll(x => string.IsNullOrEmpty(x.inNode));
                if (usefulInfos.Count > 0)
                {
                    bridgeInfo = usefulInfos[0];
                }
            }

            if (bridgeInfo == null)
            {
                var show = new ShowMode();
                var info = new BridgeInfo(parentName, panelName, show, null, 0);
                bridge = bridgePool.Allocate(info, parentPanel);
            }
            else
            {
                bridge = bridgePool.Allocate((BridgeInfo)bridgeInfo, parentPanel);
            }
            return(bridge);
        }
        /// <summary>
        /// 互斥面板自动隐藏
        /// </summary>
        /// <param name="childPanel"></param>
        /// <param name=""></param>
        /// <param name="bridge"></param>
        protected void TryHandleMutexPanels(IUIPanel childPanel, BridgeInfo bridge)
        {
            if (bridge.showModel.mutex != MutexRule.NoMutex)
            {
                if (bridge.showModel.mutex == MutexRule.SameParentAndLayer)
                {
                    var mayBridges = Bridges.FindAll(x => x.inNode == bridge.inNode);

                    foreach (var bg in mayBridges)
                    {
                        if (bg.showModel.mutex != MutexRule.SameParentAndLayer)
                        {
                            continue;
                        }

                        var mayPanels = createdPanels.FindAll(x =>
                                                              x.Name == bg.outNode &&
                                                              x.UType.layer == childPanel.UType.layer &&
                                                              x != childPanel &&
                                                              !IsChildOfPanel(childPanel, x));

                        foreach (var mayPanel in mayPanels)
                        {
                            if (mayPanel != null && mayPanel.IsShowing)
                            {
                                if (mayPanel.UType.layerIndex > childPanel.UType.layerIndex)
                                {
                                    HidePanelInteral(mayPanel, childPanel);
                                }
                                else
                                {
                                    HidePanelInteral(childPanel, mayPanel);
                                }
                            }
                        }
                    }
                }
                else if (bridge.showModel.mutex == MutexRule.SameLayer)
                {
                    var mayPanels = createdPanels.FindAll(x => x.UType.layer == childPanel.UType.layer && x != childPanel && !IsChildOfPanel(childPanel, x));
                    foreach (var mayPanel in mayPanels)
                    {
                        if (mayPanel != null && mayPanel.IsShowing)
                        {
                            if (mayPanel.UType.layerIndex > childPanel.UType.layerIndex)
                            {
                                HidePanelInteral(mayPanel, childPanel);
                            }
                            else
                            {
                                HidePanelInteral(childPanel, mayPanel);
                            }
                        }
                    }
                }
            }
        }
        ///  <summary>
        /// 自动打开子面板
        /// </summary>
        /// <param name="content"></param>
        /// <param name="parentPanel"></param>
        protected void TryAutoOpen(Transform content, IUIPanel parentPanel = null)
        {
            var panelName   = parentPanel == null ? "" : parentPanel.Name;
            var autoBridges = Bridges.FindAll(x => CompareName(x.inNode, panelName) && x.showModel.auto);

            if (autoBridges != null)
            {
                foreach (var autoBridge in autoBridges)
                {
                    InstencePanel(parentPanel, autoBridge.outNode, -1, content);
                }
            }
        }
示例#4
0
        ///  <summary>
        /// 自动打开子面板
        /// </summary>
        /// <param name="content"></param>
        /// <param name="parentPanel"></param>
        protected void TryAutoOpen(IUIPanel parentPanel = null)
        {
            var panelName   = parentPanel == null ? "" : parentPanel.Name;
            var autoBridges = Bridges.FindAll(x => CompareName(x.inNode, panelName) && x.showModel.auto);

            if (autoBridges != null)
            {
                foreach (var autoBridge in autoBridges)
                {
                    panelName = autoBridge.outNode;

                    UIInfoBase uiNode;

                    Nodes.TryGetValue(panelName, out uiNode);

                    if (uiNode == null)
                    {
                        Debug.LogError("无配制信息:" + panelName);
                        continue;
                    }

                    Bridge bridge;
                    if (!TryOpenOldPanel(panelName, uiNode, parentPanel, out bridge))
                    {
                        if (CreateInfoAndBridge(panelName, parentPanel, -1, uiNode, out bridge))
                        {
                            CreatePanel(uiNode, bridge, parentPanel);
                        }
                        else
                        {
                            Debug.LogError("找不到信息:" + panelName);
                        }
                    }
                }
            }
        }