Exemple #1
0
    private void AddNodes(JsonLoader.JsonRoot jsonRoot)
    {
        Destroy(_nodesObject);
        _nodesObject = new GameObject("Nodes");
        _nodesObject.transform.parent = transform;

        foreach (var jsonNode in jsonRoot.nodes)
        {
            var springyNode = _forceDirectedGraph.CreateNewNode();

            var nodeObject = CreateNode(springyNode, jsonNode.name);
            nodeObject.transform.parent = _nodesObject.transform;
        }
    }
Exemple #2
0
    private void AddEdges(JsonLoader.JsonRoot jsonRoot)
    {
        Destroy(_edgesObject);
        _edgesObject = new GameObject("Edges");
        _edgesObject.transform.parent = transform;

        foreach (var jsonEdge in jsonRoot.edges)
        {
            var sourceNode  = _nodesObject.transform.GetChild(jsonEdge.source).gameObject;
            var targetNode  = _nodesObject.transform.GetChild(jsonEdge.target).gameObject;
            var springyEdge = _forceDirectedGraph.CreateNewEdge(sourceNode.GetComponent <Node>().springyNode, targetNode.GetComponent <Node>().springyNode, jsonEdge.value);

            var edgeObject = CreateEdge(springyEdge, sourceNode, targetNode);
            edgeObject.transform.parent = _edgesObject.transform;
        }
    }