I have an error in the console which says - CoordinateLabeler.cs(60,33): error CS1061: ‘GridManager’ does not contain a definition for ‘GetNode’ and no accessible extension method ‘GetNode’ accepting a first argument of type ‘GridManager’ could be found (are you missing a using directive or an assembly reference?)
I have also gone through Gary’s script and that didn’t fix the error either
cs(60,33)- Node node = gridManager.GetNode(coordinates);
HERE’S MY SCRIPT
[ExecuteAlways]
[RequireComponent(typeof(TextMeshPro))]
public class CoordinateLabeler : MonoBehaviour
{
[SerializeField] Color defaultColor = Color.white;
[SerializeField] Color blockedColor = Color.grey;
[SerializeField] Color exploredColor = Color.blue;
[SerializeField] Color pathColor = Color.cyan;
TextMeshPro label;
Vector2Int coordinates = new Vector2Int();
GridManager gridManager;
void Awake()
{
gridManager = FindObjectOfType<GridManager>();
label = GetComponent<TextMeshPro>();
label.enabled = false;
DisplayCoordinates();
}
void Update()
{
if (!Application.isPlaying)
{
DisplayCoordinates();
UpdateObjectName();
label.enabled = true;
}
SetLabelColor();
ToggleLabels();
}
void DisplayCoordinates()
{
coordinates.x = Mathf.RoundToInt(transform.parent.position.x / UnityEditor.EditorSnapSettings.move.x);
coordinates.y = Mathf.RoundToInt(transform.parent.position.z / UnityEditor.EditorSnapSettings.move.x);
label.text = coordinates.x + "," + coordinates.y;
}
void UpdateObjectName()
{
transform.parent.name = coordinates.ToString();
}
void SetLabelColor()
{
if (gridManager == null)
{ return; }
Node node = gridManager.GetNode(coordinates);
if (node == null)
{ return; }
if (!node.isWalkable)
{
label.color = blockedColor;
}
else if (node.isPath)
{
label.color = pathColor;
}
else if (node.isExplored)
{
label.color = exploredColor;
}
else
{
label.color = defaultColor;
}
}
void ToggleLabels()
{
if (Input.GetKeyDown(KeyCode.C))
{
label.enabled = !label.IsActive();
}
}
}```