Ejemplo n.º 1
0
        IEnumerator CreateGraphInspector(GraphModel model)
        {
            isSpawning = true;
            layout.Stop();
            model.SortRelations();
            var parent = layout.GetNode(model.Parent);
            var center = layout.GetNode(model.Center);

            if (center == null)
            {
                center = layout.CreateNode(model.CenterInfo(), parent?.mTransform, nodeBox, 0f, model.Center);
                center.AddListeners(OnSimpleTap, OnTouchNode, OnDragStart, OnDragEnd);
            }
            yield return(null);

            center.Show();
            List <NodeInfo> nodes   = model.GetVirtualNodes();
            List <RGNode>   viewers = new List <RGNode>(model.Nodes.Count);
            List <LinkInfo> edges   = null;

            if (nodes.Count > 0)
            {
                edges = model.GetVirtualLinks();
            }
            else
            {
                nodes = model.GetNodes();
                edges = model.GetLinks();
            }
            for (int i = 0; i < nodes.Count; i += 1)
            {
                LinkInfo e = model.GetEdge(nodes[i].UID, model.Center);
                if (e != null)
                {
                    radius = e.InitLength;
                }
                var item = layout.CreateNode(nodes[i], center.mTransform, nodeBox, radius, model.Center);
                item.AddListeners(OnSimpleTap, OnTouchNode, OnDragStart, OnDragEnd);
                viewers.Add(item);
                yield return(null);
            }
            for (int i = 0; i < viewers.Count; i += 1)
            {
                viewers[i].Show();
            }
            yield return(new WaitForSeconds(0.2f));

            center.IsHighlight = true;
            isSpawning         = false;
            for (int i = 0; i < edges.Count; i += 1)
            {
                layout.CreateEdge(edges[i], edgeBox, model.Center);
                yield return(null);
            }
            layout.Begin();
            // DFNotifyManager.SendNotify(DFNotifyType.OnUIRefresh, "");
        }