private void updateUVs(ref Vector2[] uv, int[] indexes, UVPosition uvPosition) { int y = rowCount - uvPosition.position / columnCount - 1; int x = uvPosition.position % columnCount; Vector2 botLeft = new Vector2(x * uvScaleX, (y + 1) * uvScaleY); Vector2 botRight = new Vector2((x + 1) * uvScaleX, (y + 1) * uvScaleY); Vector2 topRight = new Vector2((x + 1) * uvScaleX, y * uvScaleY); Vector2 topLeft = new Vector2(x * uvScaleX, y * uvScaleY); Vector2[] rotationArray = new Vector2[8]; rotationArray[0] = topLeft; rotationArray[1] = topRight; rotationArray[2] = botRight; rotationArray[3] = botLeft; rotationArray[4] = topLeft; rotationArray[5] = topRight; rotationArray[6] = botRight; rotationArray[7] = botLeft; topLeft = rotationArray[uvPosition.rotation]; topRight = rotationArray[uvPosition.rotation + 1]; botRight = rotationArray[uvPosition.rotation + 2]; botLeft = rotationArray[uvPosition.rotation + 3]; uv[indexes[0]] = botLeft; uv[indexes[1]] = botRight; uv[indexes[2]] = topLeft; uv[indexes[3]] = topLeft; uv[indexes[4]] = botRight; uv[indexes[5]] = topRight; }
public void randomizeFaces(int atlasIdLimit) { UVPosition[] positions = new UVPosition[] { _front, _back, _left, _right, _top, _bottom }; for (int i = 0; i < positions.Length; i++) { int face = Random.Range(0, atlasIdLimit); int rotation = Random.Range(0, 4); positions[i].position = face; positions[i].rotation = rotation; } updateMesh(); }