- Home /
SkinnedMeshRenderer UV scale problem.
I have a cube with UV in 0-1 space. skinned to 1 bone as shown in picture. there is a script to scale its uv to half at start. when I return back to editor, the uv remains at its half , not reset. when I press play again, it continues to resize to its half ( now a quarter of original UV). it happens on the Skinned gameobject. whether it is GetComponent or GetComponentInChildren. also when instantiate from resources folder, it still has the problem. if tested on a static mesh, uv reset to original. only way to solve it is to reimport or change code to scale it back. is it a bug or I did some wrong? sample cube texture and script hosted here
function I used:
public void ScaleUV()
{
Mesh mesh = gameObject.GetComponentInChildren<SkinnedMeshRenderer> ().sharedMesh;
Vector2 []uvs = mesh.uv;
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2 (uvs[i].x *2, uvs[i].y *2);
}
mesh.uv = uvs;
}
Your answer
Follow this Question
Related Questions
How do I generate a Sphere with proper UVs? 1 Answer
Convert World to UV coordinates 0 Answers
Creating cube in script/ texture stretches on all sides but top and bottom? 1 Answer
uv layout problem 0 Answers
Wrong import of UV from blender 1 Answer