Referencing an object instance from a list

Thanks for looking. This is the error:
NullReferenceException: Object reference not set to an instance of an object
SelectionsManager.CheckPointerTool () (at Assets/Scripts/Utility/SelectionsManager.cs:91)
SelectionsManager.Update () (at Assets/Scripts/Utility/SelectionsManager.cs:43)

I understand it’s telling me that I’m not referring to an instance of an object. Basically, I’m trying to get objects one at a time from a list of objects. But the objects that I’m pulling from the the list don’t seem to be pointing to the instance of the objects.

public List<GameObject> selectionList = new List<GameObject>();
if (selectionList.Count >= 1)
            {
                foreach (GameObject obj in selectionList)
                {
                    checkObject = obj;
                    RemoveFromSelection(checkObject);
                    checkObject.GetComponent<SelectionDisplay>().TurnOnSelectedObject();
                }
            }

So it looks like checkObject isn’t pointing at an instance. Does anyone know how to do this? Thx

ALWAYS the same steps for a null ref, ALWAYS. It never changes. Just like War.

Some notes on how to fix a NullReferenceException error in Unity3D

  • also known as: Unassigned Reference Exception
  • also known as: Missing Reference Exception

http://plbm.com/?p=221

The basic steps outlined above are:

  • Identify what is null
  • Identify why it is null
  • Fix that.

Expect to see this error a LOT. It’s easily the most common thing to do when working. Learn how to fix it rapidly. It’s easy. See the above link for more tips.

This is the kind of mindset and thinking process you need to bring to this problem:

Step by step, break it down, find the problem.