Null reference not being set?

I’m having a major headache trying to figure this out. Any help would be apreciated.

Somewhere in my Game I have the following code:

class Line {
  var choiceList:List.<SingleChoice> = null;
      
  function Line(newText:String) {
    this.choiceList=null;
    this.text=newText;
  }
 
  function Line(newText:String,face:Texture2D,sound:AudioClip) {
    this.choiceList=null;
    this.text=newText;
    this.face=face;
    this.sound=sound;
  }
}

I omitted most of it but rest assured I have no more references to the choiceList atribute in this class.

Later I decided to build a conversation editor which includes this piece of code:

var currentLine:Line;
(...)
Debug.Log(currentLine.choiceList.Count);
if (currentLine.choiceList==null) {
  currentLine.choiceList=new List.<SingleChoice> ();
  currentLine.choiceList.Add(new SingleChoice());
}

Why does Debug.Log print a List of size 0? And why is currentLine.choiceList==null never true? I turned on #pragma strict to make sure I wasn’t doing some weird dynamic typing mishap but that doesn’t seem to be the case. I’ve even done partial rewrites of my code! As I said earlier, any tips on solving this issue would make my day. Thanks!

I guess your class is being serialized by Unity, right? Unity initializes all serialized variables automatically, otherwise it can’t serialize it. Also keep in mind that Unity’s serializatio doesn’t support inheritance. Unity serializes all public members as the type they are declared, not the actual type.