Hey,
I’m experiencing a NullReferenceException whenever I try to access a TextAsset from an array that I’ve defined in the Unity Editor.
var partyfiles : TextAsset[];
var party = new Array();
function Awake() {
instance = this;
DontDestroyOnLoad(gameObject);
}
function Start() {
InitializeHeroes();
}
//Function to load party from text files
function InitializeHeroes(){
var charReader : CharacterReader;
party = new Hero[partyfiles.length];
for(var i=0; i<partyfiles.length; i++){
party.push(charReader.BuildCharacter(partyfiles*));*
- }*
}
In the editor, I’ve attached the script to an empty game object and set the array to length 2 with text assets in each member of the array, but the game then stops and says that a NullReferenceException has occurred. Any thoughts on why this would be and how I’d go about amending it?