How do I modify this script so that instead of creating a standard cube, it instead creates a prefab, which can be specified from within the inspector? For example, instead of creating a cube when the button is clicked, it creates a building, or a tree, or a sherbet lemon.
var distance = 5;
function OnGUI ()
{
if (GUI.Button(Rect(25,25,100,30), "Place Block"))
{
var newCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
newCube.transform.position = transform.position + transform.forward * distance;
newCube.transform.rotation = transform.rotation;
}
}