Load prefabs via scripts.

Sounds like it should be easy right. I have created a plane with a number of child components including materials and added in as a prefab in unity editor.

Now, how would I go about instantiating that prefab object and its children through script? I am clearly missing something basic here. I am scripting in c#.

All examples I have seen use pre existing types and seem to magically create the prefab

From the documentation http://unity3d.com/support/documentation/Manual/Instantiating%20Prefabs.html

var cube : Transform;
function Start () {
    for (var y = 0; y < 5; y++) {
        for (var x = 0; x < 5; x++) {
            var cube = Instantiate(cube, Vector3 (x, y, 0), Quaternion.identity);
        }
    }
}

How does my cube transform object know its is the prefab cube? To me it looks like a null member of type transform. In my case, how would I instantiate a prefabed game object named “BloomPlane”?

Not sure if thisll help, but instead of Transform type, try using GameObject type, ie.
var cube : GameObject;

If you look at the GameObject that this script is attached to in the editor, there will be a place where you can drag and drop the cube prefab into the slot named “cube”. Once you have set the prefab that way, it will not be a null transform. It will be the transform of the prefab you selected.

Ok. I see that now. Thank you. RTFM

However, I am still confused about the creation of Prefabs from scratch. I am trying to create a number of prefabs and created them at random (and tweak a few parameters such as position, colour). Does that mean that any script I that need the prefabs need to have all the prefabs I want associated with the script ahead of time. I can’t just assume that prefabs are accessible as assets and instantiate them based on their name?

Actually, you can.

And there you have it. Thank you! Exactly what I was looking for!

Perhaps that should be referenced in the tutorial url http://unity3d.com/support/documentation/Manual/Instantiating%20Prefabs.html

Thanks again.