setting UVs through code: Nothing happens

Hi everyone,

I’m trying to learn how UV editing works through Probuilder API, and I have this simple example:

List<Vector4> uvs = new List<Vector4>();

pbMesh.GetUVs(0, uvs);

// Random Vector4 for testing purpose
List<Vector4> newUvs = new List<Vector4>() 
{
    new Vector4(1.5f, 5.4f, 8.4f, 68.4f),
    new Vector4(9.4f, 4.2f, 3.8f, 3.9f),
    new Vector4(5.4f, 6.1f, 1.2f, 9.3f),
    new Vector4(4.3f, 9.1f, 6.2f, 7.3f) 
};

pbMesh.SetUVs(0, newUvs);
pbMesh.RefreshUV(pbMesh.faces);
pbMesh.Refresh();

Problem is, nothing happens, UVs are not updated. What’s weird is that if I open the Probuilder UV editor and do any modification to a vertex or edge, then the above code works: The UVs are updated.

What am I missing out?

I figured it out. Don’t know if this is the best solution, but here goes:

// Use this code before UV operations
foreach(Face f in pbMesh.faces)
{
    f.manualUV = true;
}