Someone else had a similar issue that they solved but didn't know how

So figured I’d mention what was going on in my project that was yielding comparable results in case it helps anyone else…

Whenever I would click the plus button to create a new node I kept getting this happening:

along with this error message:

I really wasn’t sure why it was doing it, but I realized what I did wrong. I may have missed it when Sam did it in the video, but there was a challenge where part of it was to change the string[] of children of the node to a List<string>, which I did during the challenge. What I didn’t do (and Sam even mentioned something like this needing to be done either earlier in this video or in another video before it) was to make sure to set the list in DialogueNode.cs:

List<string> children = new List<string>();

Anyway, just thought I’d mention this in case anyone else was struggling there like I was!

Good job sorting that.

This is one of those things that people know, after working with Lists and Dictionaries over time, that the declaration should include an initialization, but then we get that in our heads and neglect to mention it to others for them to discover along the way. Over time, you’ll find that whenever you declare a collection (List, Dictionary, Queue, Stack), you’ll just initialize it without thinking about it.

Privacy & Terms