Пример #1
0
        private Panel CreateInitialPanel(PanelProperties properties, Panel anchor, Direction anchorDirection, HashSet <Transform> createdTabs)
        {
            Panel panel = null;

            for (int i = 0; i < properties.tabs.Count; i++)
            {
                PanelTabProperties panelProps = properties.tabs[i];
                if (panelProps.content)
                {
                    if (createdTabs.Contains(panelProps.content))
                    {
                        continue;
                    }

                    if (panelProps.content.parent != RectTransform)
                    {
                        panelProps.content.SetParent(RectTransform, false);
                    }

                    PanelTab tab;
                    if (panel == null)
                    {
                        panel = PanelUtils.CreatePanelFor(panelProps.content, this);
                        tab   = panel[0];
                    }
                    else
                    {
                        tab = panel.AddTab(panelProps.content);
                    }

                    tab.Icon    = panelProps.tabIcon;
                    tab.Label   = panelProps.tabLabel;
                    tab.MinSize = panelProps.minimumSize;
                    tab.ID      = panelProps.id;

                    createdTabs.Add(panelProps.content);
                }
            }

            if (panel != null)
            {
                panel.ActiveTab = 0;

                if (anchor != null && anchorDirection != Direction.None)
                {
                    panel.DockToPanel(anchor, anchorDirection);
                }
            }

            return(panel);
        }
Пример #2
0
        private Panel CreateInitialPanel(PanelProperties properties, Panel anchor, Direction anchorDirection, HashSet <Transform> createdTabs)
        {
            Panel panel = null;

            for (int i = 0; i < properties.tabs.Count; i++)
            {
                PanelTabProperties panelProps = properties.tabs[i];
                if (panelProps.content != null && !panelProps.content.Equals(null))
                {
                    if (createdTabs.Contains(panelProps.content))
                    {
                        continue;
                    }

                    if (panelProps.content.parent != RectTransform)
                    {
                        panelProps.content.SetParent(RectTransform, false);
                    }

                    int tabIndex = 0;
                    if (panel == null)
                    {
                        panel = PanelUtils.CreatePanelFor(panelProps.content, this);
                    }
                    else
                    {
                        tabIndex = panel.AddTab(panelProps.content);
                    }

                    panel.SetTabTitle(tabIndex, panelProps.tabIcon, panelProps.tabLabel);
                    panel.SetTabMinSize(tabIndex, panelProps.minimumSize);

                    createdTabs.Add(panelProps.content);
                }
            }

            if (panel != null)
            {
                panel.ActiveTab = 0;

                if (anchor != null && anchorDirection != Direction.None)
                {
                    panel.DockToPanel(anchor, anchorDirection);
                }
            }

            return(panel);
        }