I have been getting Nullreference error when I try
NodeList[lcv].MasterNode == TestNode
in the NodeManager class.
The classes in use
public class NodeManager : MonoBehaviour {
private static int InitialListSize = 100;
public NodeAccountant[] NodeList = new NodeAccountant[InitialListSize];
public int NodeCount = 0;
public class NodeAccountant {
public Node MasterNode = new Node();
public int[] Neighbors = new int[10];
public int NieghborCount = 0;
}
// Use this for initialization
void Start () {
for(int lcv = 0; lcv < NodeList.Length; lcv++)
{
NodeList[lcv] = new NodeAccountant();
NodeList[lcv].NieghborCount = 0;
}
}
....
}
public class Node : MonoBehaviour {
public string Team {get; private set;}
public int NodeIDNum;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void GenerateNode(string TeamName)
{
Team = TeamName;
}
public bool IsAlive()
{
return(GetComponentInChildren() != null);
}
}
I know MonoBehavior classes freak out when you use new so I was wondering how do I resolve this issue.
Any help would be greatly appreciated.
On edit added more to NodeManager.