create game object on the fly

hi, i am using this meshserializer from there is a loading mesh using WWW. that is getting a mesh from a url, and put it onto a gameobject.

on that webpage, the tutorial is adding a mesh filter component into an already created game object. but what i am trying to do a little bit different,

i want to create a new game object for each mesh that i downloaded using WWW. that is why i need to create a new game object for each of them.

my code so far is like this. but it is not doing what i thought it would do. the results are just two meshes instead 4 meshes. and the hierarchy is not correct either, and it has "(clone)" on created game object when i ran the game.

function Start()
    var urls = new Array ();  
    urls.Add( "http://localhost/akubz_shards/game/assets/" );
    urls.Add( "http://localhost/akubz_shards/game/assets/") ;
    urls.Add( "http://localhost/akubz_shards/game/assets/"   );
    urls.Add( "http://localhost/akubz_shards/game/assets/");

    log =  GameObject.Find("LogMessages").GetComponent(GUIText);
    var container =  GameObject.FindGameObjectsWithTag("charContainer");
    for(var i=0;i<urls.length;i++){
        var download = WWW(urls*);*
 *yield download;*
 *var mesh = MeshSerializer.ReadMeshFromWWW( download );*
 *if (!mesh)*
 *log.text +=  "Failed to load mesh 
" ;*
 _log.text +=  "
Mesh loaded from "  + urls*;*_
 _*var newGO=GameObject.Find("emptyCharContainer");*_
 _*Instantiate(newGO, transform.position, transform.rotation);*_
 _*var meshFilter : MeshFilter = newGO.GetComponent(MeshFilter);*_
 _*if( !meshFilter ) {*_
 _*meshFilter = newGO.AddComponent(MeshFilter);*_
 <em>_log.text += "
  filter " + urls*;*_</em>
 <em>_*meshFilter.mesh = mesh;*_</em>
 <em>_*//make it a children of current object*_</em>
 <em>_*newGO.transform.parent = transform;*_</em>
 <em><em>_log.text += "
Finish Loading mesh from " + urls*;*_</em></em>

and it has "(clone)" on created game object when i ran the game.

Every time you instantiate a prefab (or game object), it'll append " (clone)" to it. You can "fix" that by setting the name yourself. Just store off the name of the object you're instantiating from, and set the `.name` property on the new one after you instantiate it.

Alternatively, if you just want an empty game object, you can `new` one off.

GameObject newEmptyGameObject = new GameObject( "gameObject name" );

if you want to create the object out of nothing just create a new GameObject and use AddComponent to add what you want to it. your current code seems correct. there might be a problem in your URLS or ...

note: if you add a component using AddComponent method, unity will add all required components automatically