コード例 #1
0
 private void DrawConnectionBetweenPanels(WooPanelNode firstPanelNode, WooPanelNode secondPanelNode, Color color)
 {
     if (firstPanelNode != secondPanelNode)
     {
         DrawVerticalLine(color, firstPanelNode.rect.position + new Vector2(-10.0f, firstPanelNode.rect.height / 2.0f), secondPanelNode.rect.position.y - firstPanelNode.rect.position.y);
     }
 }
コード例 #2
0
        public void SortChildren(WooPanelNode panel)
        {
            panel.Children.Sort((x, y) => x.HierarchyIndex.CompareTo(y.HierarchyIndex));

            for (int i = 0; i < panel.Children.Count; i++)
            {
                SortChildren(panel.Children[i]);
            }
        }
コード例 #3
0
        public WooPanelNode GetOrCreatePanelNode(WooPanel panel)
        {
            WooPanelNode panelNode;

            if (!panelNodes.ContainsKey(panel))
            {
                panelNode       = new WooPanelNode();
                panelNode.Panel = panel;
                panelNodes.Add(panel, panelNode);
            }
            else
            {
                panelNode       = panelNodes[panel];
                panelNode.Panel = panel;
            }

            return(panelNode);
        }
コード例 #4
0
        public void Rebuild()
        {
//			if (isBuilt && !Application.isPlaying)
//			{
//				return;
//			}

            InitializePanels();
            prevTime = DateTime.Now;

            isBuilt = true;

            allRootNodes          = new Dictionary <Transform, List <WooPanelNode> >();
            rootsHierarchyIndeces = new Dictionary <Transform, int>();

            var panels = GetAllOnScene <WooPanel>();

            foreach (var key in panelNodes.Keys)
            {
                panelNodes[key].Panel    = null;
                panelNodes[key].Children = new List <WooPanelNode>();
            }

            for (int i = 0; i < panels.Count; i++)
            {
                WooPanelNode panelNode = GetOrCreatePanelNode(panels[i]);

                WooPanel parentPanel = GetParentPanel(panels[i]);

                if (parentPanel != null)
                {
                    WooPanelNode parentNode = GetOrCreatePanelNode(parentPanel);
                    panelNode.Parent = parentNode;
                    parentNode.Children.Add(panelNode);
                    panelNode.ParentTransform = parentNode.Panel.transform;
                }
                else
                {
                    var parentTransform = panels[i].transform.parent;

                    if (parentTransform != null)
                    {
                        if (allRootNodes.ContainsKey(parentTransform))
                        {
                            allRootNodes[parentTransform].Add(panelNode);
                        }
                        else
                        {
                            List <WooPanelNode> rootNodes = new List <WooPanelNode>();
                            rootNodes.Add(panelNode);

                            allRootNodes.Add(parentTransform, rootNodes);
                        }
                    }

                    panelNode.ParentTransform = parentTransform;
                }
            }


            RemoveNullPanels();
            SortNodes();
            if (Application.isPlaying)
            {
                EnableAll();
                InitPanels();
            }
        }