Hy all! How can I change the lookout of an object? I tried to change the mesh, but only the meshfilter changed, I can see the same ingame with this code:
where m is a MeshFilter variable. Tried this too:
GameObject i=Instantiate(Resources.Load("spy",typeof(GameObject))) as GameObject; this.gameObject.GetComponent<MeshFilter>().mesh=i.GetComponent<MeshFilter>().mesh;
this didn't achieved anything... Tried this:
Vector3 pos=this.gameObject.transform.position; Vector3 rot=this.gameObject.transform.eulerAngles; Vector3 sc=this.gameObject.transform.localScale; Destroy(this.gameObject); GameObject g=Instantiate(Resources.Load("spy"),pos,Quaternion.identity) as GameObject; g.transform.localScale=new Vector3(822.7944F,822.7944F,822.7925F);
It achieved the old object has destroyed, but the new one has the same size as the original, but looks like squashed. The collider has good size too.
I don't know what should I do to change the lookout of an object... Please help me!
You can replace the object's mesh this way:
If the object has a mesh collider, you must update it too:
NOTE: Be aware that the mesh collider update is a heavy operation, and may make your game crawl like a wounded snail if done each Update!