Hi Community, my first thread
im working on a dungeon crawler and have to rotate the floor-UVs of each sector upon its final alignments in the random generated dungeon.
it works fine, but i get the exception “mesh.uv is out of bounds” for every operation.
now my question is should i ignore it or does somebody know how to fix that ?
thanks in advance
i get this exception after i apply a saved UV-Array back to a mesh:
child.GetComponent<MeshFilter>().mesh.uv = Sector[sectorIndex].turnedUVs;
how i save the UVs to Array:
foreach (Transform child in sectorLevel.transform)
{
if (child.tag == "turnUV")
{
Vector2[] sourceUV = child.GetComponent<MeshFilter>().mesh.uv;
for (int i = 0; i < sourceUV.Length; i++)
{
sourceUV[i] = Quaternion.AngleAxis(LevelMap[x, y].rotation * -90, Vector3.forward) * (sourceUV[i] - new Vector2(2.0f, 2.0f));
sourceUV[i] += new Vector2(2.0f, 2.0f);
}
child.GetComponent<MeshFilter>().mesh.uv = sourceUV;
LevelMap[x, y].turnedUVs = sourceUV;
}
}
