public void FindAStarPath() { if (startNode != null && endNode != null) { int weightValue = int.Parse(AstarInput.text); // Execute Shortest Path. FindPath finder = gameObject.GetComponent <FindPath>(); List <Transform> paths = finder.findAstarPath(startNode, endNode, weightValue); foreach (Transform path in paths) { Renderer sr = path.GetComponent <Renderer>(); sr.material.color = Color.yellow; } } }