Once again, adding GameObjects to an array

This question seems to have been asked dozens of times all over the place, but for some reason I’m still having trouble with it.

I have several GameObjects (in the Hierarchy) called page_##, starting with page_00. I want to add these to an array.

This is my code:

static var currentPageNumber : int = 0;
static var totalPageCount : int = 5;

static var pageFinder : GameObject[];

function Start () {
	var paddedPage : String;
	var page : GameObject;
	for(var i = 0; i < totalPageCount; i++) {
		paddedPage = i.ToString("00");
		page = GameObject.Find("page_"+paddedPage);
		pageFinder *= page;*
  • }*
    It makes it to the Debug.Log() just fine:
    page_00 (UnityEngine.GameObject)
    But when I try to add it to the array, I get an error:
    NullReferenceException: Object reference not set to an instance of an object
    (wrapper stelemref) object:stelemref (object,intptr,object)
    What am I doing wrong? Do the pages have to be initiated somehow because they’re in the Hierarchy and not dynamically generated?

You haven’t initialized the pageFinder array anywhere; you only declared the variable, so it’s null.