DontDestroyOnLoad mesh destroyed

Hi.

I attached this code to main character.

function Awake () {
   DontDestroyOnLoad (transform.gameObject); 
  var childs = gameObject.GetComponentsInChildren (GameObject or Transform); 
 for (x in childs){ 
  DontDestroyOnLoad (x.renderer.mesh);     
 }   
  DontDestroyOnLoad(transform.Find("Bip01_Pelvis").gameObject.mesh);
 }

Then, I think I did everything what I can.

But error code says .mesh is not member of gameobject.

So how can I preserve .mesh when go to another scene?

Thanks.

474087--16661--$meshNull.PNG

There is no mesh property directly on the Game Object class, check the scripting reference:

…and you do not need to use DontDestroyOnLoad with every component. Simply write DontDestroyOnLoad(this) and this should work with the entire gameObject your script is attached to.

so what is right method?

(this) also result same. mesh destroyed.

leegod,

You need to call the DontDestroyOnLoad() method on the mesh. To get a reference for the mesh you need to find the MeshFilter component and use the mesh property on it.

Hi.
So I did like,

function Awake(){
var mesh : Mesh = GetComponentInChildren(MeshFilter).mesh;
DontDestroyOnLoad(mesh);
}

But still the same.
If I load scene again, there are 2 main character in the scene.
And one character from previous scene’s mesh looks destroyed.