modify a mesh that is from an fbx import

So, i have an animated humanoid model that was from an fbx import. The model is made a few meshes (head, arms, legs body) and bones for animation. I have the animations all chopped up etc etc. and works as is.

So, the issue is trying to modify a mesh of a specific body part. I have made some code to modify a mesh in C# that works well when using it on a cube or some other primitive shape, but it does not work at all on the model (or its body parts) i imported.

For example, if i attach the script to the model’s head, it will change the texture, angle, and material of the head, but the vertices of the mesh does NOT change…and thats the most important part. However, attach this same script to a cube or something, it it works as intended.

So, I can only guess that the skinned mesh within my model is making things difficult? I have no idea why its not updating/changing. Does anybody have any clues to why i cant change the verts at run time? I do some stuff at Start() and Update(), even tho i wont need to update anything if this works as intended (its a one time/loading change)

If you want to see code, check this out, the code is more or less the same.
http://unity3d.com/support/documentation/ScriptReference/Mesh.html

thanks for your help

the code is literally the code from the examples, but I foudn out what to do.

Changing the mesh for a skinned mesh object does nothing. What you have to do is change the “sharedMesh” instead. The problem is that if your model is a prefab, any changes you make will permanently change the prefab (without saving, quitting, or anything like that)!

WTF??? This is not good, and makes no sense.

Here’s a snippet of code that I know works.
You should be able to apply this to any object, and it will randomly tweak all the verts.
If this doesn’t work, I would guess it is a conflict with the bones.

// load the vertices
	var mesh : Mesh = gameObject.GetComponent(MeshFilter).mesh;
	var vertices : Vector3[] = mesh.vertices;
// step through and multiply the coordinates of each point, in effect scaling that point a random amount from the origin	
	for(i=0 ; i<vertices.length ; i++)
	{
		vertices _*= Random.Range(0.9, 1.1);_
  • }*
    *// apply the vertex changes back to the mesh, recalc normals & bounds *
  • mesh.vertices = vertices;*
  • if (recalculateNormals) *
  •  mesh.RecalculateNormals();*
    
  • mesh.RecalculateBounds();*