- Home /
uv sub meshes in cube c#
I generate a cube in code but the thing is the uv maps i do not know what to do
as you see in the code i have uvs set for 4 sides of the cube but the other two sides i dont know how to set up the uvs so that all the sides i can texture them, any idea? The only thing i know that will work is by making more vertices but im hoping there is a different way thank you in advance
PlanetMesh.subMeshCount = 6;
BVerts = new Vector3[8] {
new Vector3(-SizeMesh, -SizeMesh, -SizeMesh) * 0.5f,
new Vector3(-SizeMesh, SizeMesh, -SizeMesh) * 0.5f,
new Vector3( SizeMesh, SizeMesh, -SizeMesh) * 0.5f,
new Vector3( SizeMesh, -SizeMesh, -SizeMesh) * 0.5f,
new Vector3( SizeMesh, -SizeMesh, SizeMesh) * 0.5f,
new Vector3( SizeMesh, SizeMesh, SizeMesh) * 0.5f,
new Vector3(-SizeMesh, SizeMesh, SizeMesh) * 0.5f,
new Vector3(-SizeMesh, -SizeMesh, SizeMesh) * 0.5f };
PlanetMesh.vertices = BVerts;
BTriangle = new int[6][] ;
BTriangle[0] = new int[6] {0, 1, 2, 0, 2, 3};
BTriangle[1] = new int[6] {3, 2, 5, 3, 5, 4};
BTriangle[2] = new int[6] {5, 2, 1, 5, 1, 6};
BTriangle[3] = new int[6] {3, 4, 7, 3, 7, 0};
BTriangle[4] = new int[6] {7, 6, 0, 0, 6, 1};
BTriangle[5] = new int[6] {4, 5, 6, 4, 6, 7};
PlanetMesh.SetTriangles(BTriangle[0], 0);
PlanetMesh.SetTriangles(BTriangle[1], 1);
PlanetMesh.SetTriangles(BTriangle[2], 2);
PlanetMesh.SetTriangles(BTriangle[3], 3);
PlanetMesh.SetTriangles(BTriangle[4], 4);
PlanetMesh.SetTriangles(BTriangle[5], 5);
PlanetMesh.RecalculateNormals();
BUvs = new Vector2[8] {new Vector2(0,0),new Vector2(1,1),new Vector2(1,0),new Vector2(0,1),new Vector2(0,0),new Vector2(1,1),new Vector2(1,0),new Vector2(0,1) };
PlanetMesh.uv = BUvs;
Comment
Your answer
Follow this Question
Related Questions
Using compute shader, how to take every vertex of a mesh and make a cube spawn and move to each one? 0 Answers
Where is the submesh Reference of vertex/triangle? 1 Answer
Do i need recalculate uv coordinate after modifying mesh vertices 0 Answers
How to split UV in Mesh 1 Answer
Mesh breaks apart when using vertex displacement with shadergraph. 3 Answers