Okay, I’m bringing in xml data, so I assume that has to be done with an array, or at least is done that way in this example: http://wiki.unity3d.com/index.php?title=Saving_and_Loading_Data:_XmlSerializer . Now since that part works, I don’t want to mess around with it unless I have to, I need to convert deck information brought in from an array into a list, so it’s easier to manipulate. Here is the bit of code that is given me an issue:
var deck = DeckContainer.Load(Path.Combine(Application.dataPath, "kdeck.xml"));
int test = deck.Dcards [0].Number;
Debug.Log (test);
int numofCards = deck.Dcards.Length;
Dcard tempcard;
Debug.Log (numofCards);
for (int c = 0; c < numofCards; c++) {
tempcard = deck.Dcards
;
playerdeck.Insert(c,tempcard);
tempcard = playerdeck[c];
Debug.Log (tempcard);
}
please note that the playerdeck list is a Dcard list so that isn't the problem. I keep the getting this error:
`NullReferenceException: Object reference not set to an instance of an object
now tempcard is a Dcard object, so I'm not quiet sure what's going on here. Note also you can't tell this from here, but deck.Dcards[] does hold Dcard objects. I can access the Dcard properties like this deck.Decards[0].Number and such, as defined in my Dcard class. Any ideas?