Hello! Since MoveActionValidate part of the course i have problem with the GridDebugObjects after struggling to identify the problem,i just copied the code from the repos and still have the problem Here is the error code
NullReferenceException: Object reference not set to an instance of an object
GridDebugObject.Update () (at Assets/Scripts/Grid/GridDebugObject.cs:21)
Here is the script using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class GridDebugObject : MonoBehaviour
{
[SerializeField] private TextMeshPro textMeshPro;
private GridObject gridObject;
public void SetGridObject(GridObject gridObject)
{
this.gridObject = gridObject;
}
private void Update()
{
textMeshPro.text = gridObject.ToString();
}
}
here is my GridObject script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GridObject
{
private GridSystem gridSystem;
private GridPosition gridPosition;
private List<Unit> unitList;
public GridObject(GridSystem gridSystem, GridPosition gridPosition)
{
this.gridSystem = gridSystem;
this.gridPosition = gridPosition;
unitList = new List<Unit>();
}
public override string ToString()
{
string unitString = "";
foreach (Unit unit in unitList)
{
unitString += unit + "\n";
}
return gridPosition.ToString() + "\n" + unitString;
}
public void AddUnit(Unit unit)
{
unitList.Add(unit);
}
public void RemoveUnit(Unit unit)
{
unitList.Remove(unit);
}
public List<Unit> GetUnitList()
{
return unitList;
}
public bool HasAnyUnit()
{
return unitList.Count > 0;
}
}
And here is the image of my unity screen inside the prefab.Showing thats its correctly assigned.I am kind of a beginner been dabbling a in a lot of tutorial course but i am not finding the problem and is polluting my console when im trying to learn. Here plz help me!