Why is my list not filling

I’m trying to work on a getting my AI to Follow procedurally generated waypoints. When I try to do this however my list is empty despite using the same syntax I had used for other list storage which worked just fine. here are examples from my code

public class GameData : MonoBehaviour {

  public List<GameObject> players;
  public List<GameObject> waypoints
}

public class InputController : MonoBehaviour {

private void Awake()
{
 //works
    Singleton.gm.GetComponent<GameData>().players.Add(gameObject);
}

public class Register_Waypoints : MonoBehaviour {

// Use this for initialization
void Awake () {
 //does not work
    Singleton.gm.GetComponent<GameData>().waypoints.Add(gameObject);
}

}

I have essentially the same thing scripted for the possible spawn points for both my player and my AI as well as the AI itself registers inside a list in the game data script and those all work just fine but for some reason the waypoints don’t show up. Why is this happening.

I think your problem is that you’re doing this in Awake. The initialization order of things isn’t deterministic or terribly predictable, which is why there are two initialization phases: Awake and Start.

When you do something in Awake, other GameObjects and Components may not be defined yet, causing a host of issues and unpredictable behavior. Use Awake for internal initialization only.

Start gets called after all active GameObjects have gone through their Awake. While the order in which the different starts are called is not defined, you know that everything has at least gone through Awake. This means that external references should work/be placed in Start.

Keep in mind that during Start, other items may not have gone through Start yet, so their state might not be quite what you expect.

Awake for internal initialization.
Start for cross-object initialization.