Example #1
0
        void GenerateEdges()
        {
            if (m_scriptData.m_scripts != null)
            {
                int size = m_scriptData.m_scripts.Count;
                NodeDependencyInfo[,] table = dependencyAnalytics.m_nodeDepInfo;
                for (int i = 0; i < size; i++)
                {
                    for (int j = 0; j < size; j++)
                    {
                        if (i != j)
                        {
                            if (table [i, j].depType != DependencyType.None && table [j, i].depType != DependencyType.None)
                            {
                                //circular
                                string         targetName = m_scriptData.m_scripts [i].m_type.Name;
                                string         sourceName = m_scriptData.m_scripts [j].m_type.Name;
                                DependencyEdge e          = new DependencyEdge(sourceName + " ---> " + targetName, m_graph.GetNode(sourceName), m_graph.GetNode(targetName), stiffness, table [i, j].depType = DependencyType.Circular);
                                m_graph.AddEdge(e);
                                m_visualEdges.Add(new VisualEdge(e, dependencyAnalytics));
                            }
                            else if (table [i, j].depType != DependencyType.None)
                            {
                                string         targetName = m_scriptData.m_scripts [i].m_type.Name;
                                string         sourceName = m_scriptData.m_scripts [j].m_type.Name;
                                DependencyEdge e          = new DependencyEdge(sourceName + " ---> " + targetName, m_graph.GetNode(sourceName), m_graph.GetNode(targetName), stiffness, table [i, j].depType);
                                m_graph.AddEdge(e);
                                m_visualEdges.Add(new VisualEdge(e, dependencyAnalytics));
                            }
                        }
                    }
                }


                if (!_settingsPage.m_allowLoners)
                {
                    List <VisualNode> tempList = new List <VisualNode> (m_visualNodes);
                    foreach (VisualNode vn in m_visualNodes)
                    {
                        bool hasEdge = false;
                        foreach (VisualEdge v in m_visualEdges)
                        {
                            if (v.m_edge.IsNodeInEdge(ref vn.m_node))
                            {
                                hasEdge = true;
                            }
                        }

                        if (!hasEdge)
                        {
                            tempList.Remove(vn);
                        }
                    }
                    tempList      = VisualNode.DistinctNodeList(tempList);
                    m_visualNodes = tempList;
                }
            }
        }
 public VisualEdge(DependencyEdge edge, DependencyAnalytics depAnalytics)
 {
     m_edge = edge;
     if (_arrowTexture == null)
     {
         _arrowTexture = UnityEngine.Resources.Load("ArrowIconWhite") as Texture;
     }
     depType += depAnalytics.IsTwoWayDependency(m_edge.m_source.m_name, m_edge.m_target.m_name) ? "2" : "1";
     depType += m_edge.m_dependencyType == DependencyType.Dirty ? "*" : "";
 }
 public VisualEdge(DependencyEdge edge)
 {
     m_edge = edge;
     if (_arrowTexture == null)
     {
         _arrowTexture = UnityEngine.Resources.Load("ArrowIconWhite") as Texture;
     }
     depType += m_edge.m_dependencyType == DependencyType.Circular ? "2" : "1";
     depType += m_edge.m_dependencyType == DependencyType.Dirty ? "*" : "";
 }
Example #4
0
        public static bool Deserialize(out List <VisualNode> nodes, out List <VisualEdge> edges)       //, out Vector2 offset)
        {
            nodes = new List <VisualNode> ();
            edges = new List <VisualEdge> ();
            try {
                if (File.Exists(DataPath()))
                {
                    byte[]       byteArray = File.ReadAllBytes(DataPath());
                    MemoryStream m         = new MemoryStream(byteArray);
                    BinaryReader br        = new BinaryReader(m);

                    int numNodes = br.ReadInt32();
                    int numEdges = br.ReadInt32();

                    for (int i = 0; i < numNodes; i++)
                    {
                        Vector2 position;
                        position.x = br.ReadSingle();
                        position.y = br.ReadSingle();

                        string nodeName = br.ReadString();
                        Node   node     = new Node(nodeName, br.ReadBoolean());

                        node.m_position = position;
                        VisualNode v = new VisualNode(node, null);
                        nodes.Add(v);
                    }


                    for (int i = 0; i < numEdges; i++)
                    {
                        string         name       = br.ReadString();
                        string         sourceName = br.ReadString();
                        string         targetName = br.ReadString();
                        DependencyType depType    = (DependencyType)br.ReadInt32();

                        DependencyEdge edge  = new DependencyEdge(name, FindNodeByName(sourceName, nodes), FindNodeByName(targetName, nodes), 1f, depType);
                        VisualEdge     vEdge = new VisualEdge(edge);

                        edges.Add(vEdge);
                    }


                    return(true);
                }
                else
                {
                    return(false);
                }
            } catch {
                return(false);
            }
        }