How to move UV's of a mesh so you can have two textures in one file

Hi,

I'd like to move the a mesh's uv.x value += 512 so it displays a different version of the objects skin that sits inside the same texture.

I've seen this:

mesh.Clear(); mesh.vertices = newVertices; mesh.uv = newUV; mesh.triangles = newTriangles;

Which seems to stretch or shrink the skin.

The end goal to is to only move certains vertices so I have some of the skin coming from one side of the texture and some of it from the other side.

Anyone know what I'm talking about?

Offsetting only a few triangle's worth of UV's is going to be needlessly complicated.. However, if you wish to offset the entire UV set of an object, i wrote this..

var xOffset = 0.0;
var yOffset = 0.0;

function Start()
{

    // Build the uvs 
    var uvs : Vector2[] = new Vector2[(GetComponent(MeshFilter) as MeshFilter).mesh.vertices.Length]; 
    uvs = (GetComponent(MeshFilter) as MeshFilter).mesh.uv; // Take the existing UVs 

    for (var i = 0 ; i < uvs.Length; i++) uvs <em>= Vector2 (uvs_.x + xOffset, uvs*.y + yOffset); // Offset all the UV's*_</em> 
 <em>_*// Apply the modded UV's*_</em> 
 <em>_*(GetComponent(MeshFilter) as MeshFilter).mesh.uv = uvs;*_</em> 
 <em>_*// Blow this shiz away*_</em> 
 <em>_*Destroy(this);*_</em>
<em>_*}*_</em>
<em>_*```*_</em>

1) Have you consider trying to achieve the effect by manipulating a material rather then animating a mesh's uvs?

Materials with texture have a tiling xy AND an offset xy.

I would highly recommend experimenting with the material in the editor before writing your script to automate it.

You will need to adjust the tiling to get the new skin to work. This will have the effect of stretching or shrinking the skin until you get it right. Next, manipulate the offset x or y. This will slide the entire texture map across the surface of your object.

Once you understand how get control over that, then write the script that manipulates the material.

2) It is difficult to understand your question without seeing it. Can you post an concept image that describes the look you are going for?

Don’t know how old this is, but I wrote a script that let’s you slide UVs in the editor visually while still batching. It’s a little buggy, but it works :slight_smile:

Link: http://ethanredd.tumblr.com/post/35949640385/simple-free-uvslider-i-wrote