List.Count returning 0 while it has 1 entry

Ive been banging my head against the wall for the last 2 hours trying to figure this out…

I have an object that has a public List in it. That list has 1 entry in it, put into it by me in the editor mode.

I start the game up, and check the count. Any objects that only have 1 object in their lists return 0 for the count, while anything more than 1 returns the correct value.

At no time are these lists being recreated, added to, removed from. I call the count while looking directly at the 1 entry in the list and still nothing.

public void FindRoute(Waypoint ending)
	{
		List<Waypoint> uncheckedWaypoints = new List<Waypoint>();
		
		for(int x = 0; x < waypointCollection.transform.GetChildCount(); x++)
		{
			uncheckedWaypoints.Add (waypointCollection.transform.GetChild(x).GetComponent<Waypoint>());
			
		}
		finishedDestination = ending;
		
		
		
		finishedDestination.myDistance = 0;
		
			
		while(uncheckedWaypoints.Count > 0)
		{
			Waypoint shortest = null;
			foreach(Waypoint way in uncheckedWaypoints)
			{
				if(shortest == null)
					shortest = way;
				if(way.myDistance < shortest.myDistance)
					shortest = way;
			}
			print (shortest.connections.Count);
			
			uncheckedWaypoints.Remove(shortest);
			if(shortest.myDistance == Mathf.Infinity)
				break;
			foreach(Waypoint connection in shortest.connections)
			{
				float newDistance = shortest.myDistance + (Vector2.Distance(shortest.gameObject.transform.position, connection.gameObject.transform.position));
				if(newDistance < connection.myDistance)
				{
					connection.myDistance = newDistance;
					connection.previousWaypoint = shortest;	
				}
			}
			
		}
		

		
	}

Calling this function on a waypoint that has only 1 connection in its list returns a 0 count.

The Waypoint class has nothing in apart from the distance and connections variables.

Edit. Attached relevant files.
See the following link for the two cs files.
http://www.plusintstudios.com/Files

I suggest you put in this script above a public variable like this:

public Waypoint debugWP;

And where you print your connections.Count do this:

debugWP = shortest;

Now you can click on the variable in the inspector and Unity will “ping” the object your function has choosen.

I guess the function uses a different Waypoint than the one you expect.

An update on the situation.

I have a fix… but it defies logic. The count will return the correct value, after I switch from Game, to the Scene tab and back to the Game tab out.

This doesnt work in a build however as actually tabbing to another window doesnt seem to do anything.