Hi, i want to make a framework to texture dynamicaly creaed meshes(textures are in atlases). The point is that i dont want to use any mainTexture options etc… there are lots of examples with using mianTexture options or similar, but this is the option of material and i have full atlas on one material and i can’t set one tiling on it as long as there are very different textures. I don’t know if i describe it correctly… i know how to set an offset and i use uvs for that.
maybe ill post some of my code here:
XmlValueReader(); //give me info about texture (to public Rect AtlasUvs)
//===items needed to change Tiling and Offset====
renderer.sharedMaterial = atlasMaterial;
Mesh mesh = GetComponent<MeshFilter>().mesh;
// Build the uvs
Vector2[] uvs = new Vector2[mesh.vertices.Length];
uvs = mesh.uv; // Take the existing UVs
for (int k = 0 ; k < uvs.Length; k++) {
uvs[k] = new Vector2 (uvs[k].x + AtlasUvs.x/fAtlasWidth, uvs[k].y + AtlasUvs.y/fAtlasHeight); // Offset all the UV's
}
mesh.uv = uvs; // Apply the modded UV's
I need to write a similar code which makes tiling to the mesh too (not to material containing full atlas)
Any clues?