I have a large volume of prefabs, and I want the user to able to select from a menu different names. These names each correspond to a specific prefab. When this happens, a specific GameObject is selected, and I would like to instantiate a prefab under that GameObject local Transform. (I am building a machine, and for each part there is a list of other possible parts than can be attached, stoed in a database. The part library is rather big. Think Toons or "The Incredible Machine" :-) ).
Later I would like to stream these components, and this is the basis for this problem.
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);
}
}
}
The current code is taken from the instantiation tutorial available at http://unity3d.com/support/documentation/Manual/Instantiating%20Prefabs.html
For this to work, I am required to put the above script into a gameObject, and then Drag the Prefab into the Cube variable slot for that script component in the inspector. This means I have to have access to all the prefabs. I would like to achieve this without the dragging. This is because the plan is to put new assets (prefabs) in my online database as this collection grows, and have the system automatically donwload (from an URL) the prefabs as needed.
Is this possible, or have I completely misunderstood the concept of Prefabs? Is there a way that I can set this variable to a streamed asset using the WWW class? ( I found this thread :http://answers.unity3d.com/questions/17376/reconnect-programmatically-instantiated-prefab but I did not understand it completely, although it might be what I am looking for).
Help is really appreciated.