I have an error in my Array, but i couldnt figure out why it was null. What am I doing wrong?
Error
NullReferenceException: Object reference not set to an instance of an object
The object that i have placed in Scroller, has 4 child game objects (planes) under it. The error states that its a problem with where I am setting the values of the levels array;
please help!
using System;
[Serializable]
public class Levels
{
public GameObject levelImage;
public GameObject locked;
public bool isLocked;
}
public class LevelSelectMenu : MonoBehaviour {
public GameObject scroller;
public Levels[] levels;
void Awake ()
{
if (scroller && levels.Length == 0)
{
int children = scroller.transform.childCount;
print (children);
levels = new Levels[children];
for (int i = 0; i < children; i++ )
{
levels*.levelImage = scroller.transform.GetChild(i).gameObject;*
levels_.locked = levels*.levelImage.transform.GetChild(i).gameObject;
levels.isLocked = GlobalState.levelStats.locked;
}
}
}
}*_