x


UV Image Map Animation

I have a monospaced image of the numbers 0 to 9 and I need to map them to a group of square planes. The end result would be a score display of six planes with the numbers 0 - 9 mapped to each. I was planning on using the UV Animator extension from the Unity Wiki but its still down (Damn hackers)

I tried playing around with GetComponent().mesh.uv[x] = new Vector2(u,v) but I cant seem to figure it out.

Right now all the planes are set to 0 so I guess all I need to do is move the UVs to the right to change the number. If I could get one of the planes working I could easily do the rest. Each plane has 4 vertices.

Also, my scripts are in C# but answers in JS are ok if its easier for you.

more ▼

asked Aug 10 '12 at 12:20 AM

Ronin6 gravatar image

Ronin6
17 2 5 10

Figured it out. Here is the answer.

Mesh mesh = GetComponent<MeshFilter>().mesh; //get mesh
Vector2[] newUVs = mesh.uv; //get current uvs

for(int i=0; i< newUVs.Length; i++)
{
  //modify uv coordinets here
  newUVs[i].x +=.5f;//move uv coords to the right
}

mesh.uv = newUVs ;//apply to mesh
Aug 10 '12 at 12:49 AM Ronin6

post it as an answer and check it solved

Aug 10 '12 at 02:02 AM Seth Bergman
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Figured it out. Here is the answer.

Mesh mesh = GetComponent<MeshFilter>().mesh; //get mesh
Vector2[] newUVs = mesh.uv; //get current uvs

for(int i=0; i< newUVs.Length; i++)
{
  //modify uv coordinets here
  newUVs[i].x +=.5f;//move uv coords to the right
}

mesh.uv = newUVs ;//apply to mesh
more ▼

answered Aug 10 '12 at 11:55 AM

Ronin6 gravatar image

Ronin6
17 2 5 10

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3785
x237
x64
x42

asked: Aug 10 '12 at 12:20 AM

Seen: 447 times

Last Updated: Aug 10 '12 at 11:55 AM