Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- All credit for this code goes to cgaudino. I just rewrote his function in js and made some minor changes.
- Don't forget to change the scale:Vector2 values to match your spritesheet. Ideally it should be passed on the function arguments.
- */
- function ChangeUV(plane:GameObject, offset:Vector2)
- {
- //Modify quad uvs
- var spriteMesh:Mesh = plane.GetComponent(MeshFilter).mesh;
- var scale:Vector2 = Vector2(0.125, 0.25);
- var uvs:Vector2[] = new Vector2[4];
- uvs[0].x = offset.x;
- uvs[0].y = offset.y - scale.y;
- uvs[1].x = offset.x + scale.x;
- uvs[1].y = offset.y;
- uvs[2].x = offset.x + scale.x;
- uvs[2].y = offset.y - scale.y;
- uvs[3].x = offset.x;
- uvs[3].y = offset.y;
- spriteMesh.uv = uvs;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement