public void Awake() { var allVisualNodes = FindObjectsOfType <VisualNode>(); foreach (var nodeFrom in allVisualNodes) { foreach (var nodeTo in allVisualNodes) { float distance = (nodeTo.transform.position - nodeFrom.transform.position).magnitude; VisualEdge oppositeEdge = new VisualEdge(); oppositeEdge.nodeFrom = nodeTo; oppositeEdge.nodeTo = nodeFrom; oppositeEdge.color = Color.white; if (nodeFrom != nodeTo && // Only if different nodes distance < 4f && // Only if close enough !visualEdges.Contains(oppositeEdge) // Only if the opposite edge is not already in ) { // Create the edge VisualEdge edge = new VisualEdge(); edge.nodeFrom = nodeFrom; edge.nodeTo = nodeTo; edge.color = Color.white; visualEdges.Add(edge); } } } }
public void Update() { foreach (var edge in currentData.allEdges) { VisualEdge visualEdge = edgeToVisualEdgeDict[edge]; Debug.DrawLine(visualEdge.nodeFrom.transform.position, visualEdge.nodeTo.transform.position, visualEdge.color); } }
public void UnselectEdge(Edge edge) { VisualEdge visualEdge = edgeToVisualEdgeDict[edge]; visualEdge.color = Color.white; }
public void SelectEdge(Edge edge) { VisualEdge visualEdge = edgeToVisualEdgeDict[edge]; visualEdge.color = Color.red; }
public override bool Equals(object obj) { VisualEdge otherEdge = (VisualEdge)obj; return(this.nodeFrom == otherEdge.nodeFrom && this.nodeTo == otherEdge.nodeTo); }