C# PackTextures & UV Mapping

I’m a tad bit confused as to how to work with the mesh and the uvs.
At a loss in RegenerateUVS(). Is there a good example of this in action? Is there a way for me to see the changes to the UV live as to make it easier to modify?

I’m getting the Rect back in uvs but I’m not sure how to cross reference that with the old uvs to get the new coords. It’s only five elements with four values for each. (X,Y,Width,Height)

I’m looking at this at the moment: http://unity3d.com/support/documentation/ScriptReference/Mesh-uv.html

I’m not sure if the calculation I made are being applied or not but if they are, it’s resulting in the same uvs.

Green is still the head which is fine. But the others are out of wack.

Red should be body, purple should be feet, blue hands, and orange for pants.

125alt text125

About the error: When calling new Material() with a string, the string is parsed as Shader source code (see documentation), but you are passing “0.0”

Other things: PackTextures() returns an array of UVs in the order of/matching the incoming Texture array. However,

  • you are calling PackTextures in Awake() and assigning the return value to “uvs”, which is good. But you alre also calling PackTextures in Update(), ignoring the return value. Is this intentional?
  • With SetAssembly() you are arranging your Texture array. However, you are then assigning the corresponding uvs.Rect to MeshFilters using the same indexing, but you gathered your MeshFilters with GetComponentsInChildren, which return Components in a differently sorted or even random order.

I managed to figure it out. I was told by a well experienced Unity developer that I was not able to change the PackTextures() build order, which was false. As such I never attempted to actually change it to see if I could get it to match my mesh.

Turns out I could and did, now the my UVS are showing correctly.