Set value on script component of prefab gameobject for later instantiation.

So I have a bunch of prefabs which I load into an array for later instantiation. There is a set of meta data that needs to be generated and a reference assigned to the prefab so its available to all instantiated clones of said prefab. This is how I’m trying to go about it:

// Load prefabs into array
GameObject[] blocks = Resources.LoadAll(contentPath, typeof(GameObject)).Cast<GameObject>().ToArray();

        foreach (GameObject go in blocks) {
            // this takes parameters but I removed them for this example.
            GSBlockMeta blockMeta = new GSBlockMeta(); 

            go.GetComponent<Block>().id = go.name;
            go.GetComponent<Block>().meta = blockMeta;

            blockList.Add(blockMeta);
            blocksById.Add(go.name, blockMeta);
        }

Now I would think that any instantiated clones from objects in that blocks array would have a reference to the associated blockMeta object. However, the result is the Block.meta field is null. Interestingly the Block.id field has the correct string value.

What have I missed?

Prefabs can’t have scene references. I suggest you assign the reference when instantiating instead. Create your instantiate method that will do that to avoid copy/paste issues.