C# : Null Reference Exception

Hello guys, here’s my question.

I’ve got 2 scripts running. There’s a class called ClassA defined on Script1, while on Script2 I instantiate an object from ClassA.

In Script2 I call a method from ClassA, which instantiates some stuff. And while running this problem, I got a NullReferenceException.

Here’s a little example of my problem:

Here is ClassA - defined in Script1

public class ClassA : MonoBehaviour {
	private GameObject InsideObject = new GameObject();
	public void changesImportantStuff()
		this.InsideObject = (GameObject)Instantiate(Resources.Load("SomeModel"));

And here is ClassFoo - defined in Script2

public class Foo : MonoBehaviour {

    public ClassA[,] someObject = new ClassA[5,5];

	public void MethodClassFoo()
        for(int i=0;i<5;i++)
	          for(int j=0;j<5;j++)
	       		this.someObject[i,j].methodA(); <- it says the error is here.

Thanks for your time!

Do you affect a value to those 25 members of someObject ? I’m not sure a jagged array is shown in the inspector so you might have to use Find / Instantiate, but either way you need values in there.