Null reference exception from list.

Hi I have a script with a list containing game objects to be added later. I am trying to access this list in another script but it is throwing a null reference exception error. Even checking if list is null throws an error. Please help.

1st script:

public List<GameObject> walkablePathObjects = new List <GameObject>();

2nd script:

[SerializeField] PathfindingToolScript pathfindingToolScript;
if (pathfindingToolScript.walkablePathObjects == null){
            return;
        }

If your if checking is throwing null, you should be debugging.

  1. Find out what is null
  2. Find out why it’s null
  3. Fix it!

So, is pathfindingToolScript null?

1 Like

It was lol, my apologies. The simplest of things get overlooked.