UV affectation with multi submeshes

Hi,
I have a serious problem with character texturing!
I’m using a character with only one mesh, and I want to apply the texture from 4 different pictures, I’ve the algorithm that allow me doing the texture correspondence (for each vertex in the mesh, the algorithm gives me : from witch picture I must get the texture and the UV coordinates on that pictures)
I’ve tried many methods but no one seems to give correct results in Unity, and now I’m working on that method:

  • I added 04 Materials to the character object in the inspector
  • I added 04 submeshes to the mesh (I don’t have the choice, it’s impossible to divide the mesh into 04 different meshes or different objects ) using :
    mesh1.subMeshCount= 4;
  • I affected the triangles array corresponding to each submesh using: mesh1.SetTriangles(triangRightTab,1);
  • Using my algorithm -I talked about at the beginning- I changed the UV map to associate the uv coordinates to each vertex !!! like that
    uvMapping = new Vector2(x,y);
    mesh.uv = uvMapping;

The problem is here, when I do that I’m talking with only one vertex array (the division of the mesh into submeshes don’t split the vertex table, it only concern the triangles table), so with these line, I can only tell to each vertex that his uv are (x,y) but I can’t tell him from witch picture (material) he will get them!!! So he is doing the mapping with only the material 0.
Am i missing anything, or is there a way to do that, help please it’s really taking me a lot of time.
Thanks in advance

Generally regarding mesh and working with UVs. Please check out these

Please be sure to vote up useful answers - I love points ! :slight_smile:

← critical information

Please read carefully this gotchya:

http://answers.unity3d.com/questions/417483/is-there-a-way-to-assign-meshverticesi-directly.html

It is critical to read and understand this:

please check out some of these

I may misunderstand you, but it’s this simple:

change the texture.

it’s just that simple.

it would be - unbelievable - to try to do UV mapping in Unity (why?)

Simply open Cheetah3D, Blender or whatever … or for professional use something like this http://www.polygonal-design.fr/e_unfold/features.php … and make up the four versions of your character.

then in Unity just change the texture.