Exemplo n.º 1
0
        public PanelTab AddTab(string tabID, int tabIndex = -1)
        {
            PanelTab tab;

            PanelNotificationCenter.TryGetTab(tabID, out tab);

            return(AddTab(tab));
        }
Exemplo n.º 2
0
        public void RemoveTab(string tabID)
        {
            PanelTab tab;

            PanelNotificationCenter.TryGetTab(tabID, out tab);

            RemoveTab(tab);
        }
Exemplo n.º 3
0
        public int GetTabIndex(string tabID)
        {
            PanelTab tab;

            if (PanelNotificationCenter.TryGetTab(tabID, out tab))
            {
                return(GetTabIndex(tab));
            }

            return(-1);
        }
        private static IPanelGroupElement Deserialize(DynamicPanelsCanvas canvas, ISerializedElement element)
        {
            if (element == null)
            {
                return(null);
            }

            if (element is SerializedDummyPanel)
            {
                return(canvas.Internal.DummyPanel);
            }

            if (element is SerializedPanel)
            {
                SerializedPanel serializedPanel = (SerializedPanel)element;
                Panel           panel           = null;

                SerializedPanelTab[] tabs = serializedPanel.tabs;
                for (int i = 0; i < tabs.Length; i++)
                {
                    PanelTab tab;
                    if (!PanelNotificationCenter.TryGetTab(tabs[i].id, out tab))
                    {
                        continue;
                    }

                    if (panel == null)
                    {
                        panel = tab.Detach();
                        canvas.UnanchoredPanelGroup.AddElement(panel);
                    }
                    else
                    {
                        panel.AddTab(tab);
                    }

                    //if( tab != null )
                    //{
                    //	tab.MinSize = tabs[i].minSize;
                    //	tab.Label = tabs[i].label;
                    //}
                }

                if (panel != null)
                {
                    if (serializedPanel.activeTab < tabs.Length)
                    {
                        int activeTabIndex = panel.GetTabIndex(tabs[serializedPanel.activeTab].id);
                        if (activeTabIndex >= 0)
                        {
                            panel.ActiveTab = activeTabIndex;
                        }
                    }

                    if (serializedPanel is SerializedUnanchoredPanel)
                    {
                        SerializedUnanchoredPanel unanchoredPanel = (SerializedUnanchoredPanel)serializedPanel;
                        panel.RectTransform.anchoredPosition = unanchoredPanel.position;
                        panel.gameObject.SetActive(unanchoredPanel.active);
                    }

                    panel.FloatingSize = serializedPanel.floatingSize;
                }

                return(panel);
            }

            if (element is SerializedPanelGroup)
            {
                SerializedPanelGroup serializedPanelGroup = (SerializedPanelGroup)element;
                ISerializedElement[] children             = serializedPanelGroup.children;
                if (children == null || children.Length == 0)
                {
                    return(null);
                }

                PanelGroup panelGroup = new PanelGroup(canvas, serializedPanelGroup.horizontal ? Direction.Right : Direction.Top);
                for (int i = 0; i < children.Length; i++)
                {
                    if (children[i] == null)
                    {
                        continue;
                    }

                    IPanelGroupElement childElement = Deserialize(canvas, children[i]);
                    if (childElement != null)
                    {
                        panelGroup.AddElement(childElement);
                        sizesHolder.Add(new GroupElementSizeHolder(childElement, children[i].size));
                    }
                }

                if (panelGroup.Count > 0)
                {
                    return(panelGroup);
                }
            }

            return(null);
        }