I have a Main scene. In this scene, I have an object called “GameController” which is where I’m keeping things like the overall score and other objects that the game needs. One is a list:
public List<myClass> myclassList = new List<myClass>();
In a second scene, I add items to the list. When I get back to the Main scene, it does give me the correct/expected Count of items in the list. But something is screwy when I’m trying to access the members of the list.
To troubleshoot, in the GameController Update method, I added the following:
if (myclassList.Count > 0) {
Debug.Log (myclassList [0].astringfrommyclass);
}
And here’s the weirdness… in my console, on the first Update, I get one correct output message with the expected string that’s in astringfrommyclass. But that’s it. then I keep getting the NullReferenceException on that line of code.
Help??
This is in Unity 2017.3.0f3 and while I’m a relatively experienced programmer, I’m new to Unity.