SHOW:
|
|
- or go back to the newest paste.
1 | void ExecuteMesh() | |
2 | { | |
3 | Mesh mesh = GetComponent<MeshFilter>().mesh; | |
4 | if (mesh.vertices.Length < 24) return; // not enough vertices | |
5 | if (mesh.vertices.Length > 24) return; // too many vertices | |
6 | Vector2[] UVs = new Vector2[mesh.vertices.Length]; | |
7 | // Front | |
8 | UVs[0] = new Vector2(0.0f, 0.0f); | |
9 | UVs[1] = new Vector2(0.333f, 0.0f); | |
10 | UVs[2] = new Vector2(0.0f, 0.333f); | |
11 | UVs[3] = new Vector2(0.333f, 0.333f); | |
12 | // Top | |
13 | UVs[4] = new Vector2(0.334f, 0.333f); | |
14 | UVs[5] = new Vector2(0.666f, 0.333f); | |
15 | UVs[8] = new Vector2(0.334f, 0.0f); | |
16 | UVs[9] = new Vector2(0.666f, 0.0f); | |
17 | // Back | |
18 | UVs[6] = new Vector2(1.0f, 0.0f); | |
19 | UVs[7] = new Vector2(0.667f, 0.0f); | |
20 | UVs[10] = new Vector2(1.0f, 0.333f); | |
21 | UVs[11] = new Vector2(0.667f, 0.333f); | |
22 | // Bottom | |
23 | UVs[12] = new Vector2(0.0f, 0.334f); | |
24 | UVs[13] = new Vector2(0.0f, 0.666f); | |
25 | UVs[14] = new Vector2(0.333f, 0.666f); | |
26 | UVs[15] = new Vector2(0.333f, 0.334f); | |
27 | // Left | |
28 | UVs[16] = new Vector2(0.334f, 0.334f); | |
29 | UVs[17] = new Vector2(0.334f, 0.666f); | |
30 | UVs[18] = new Vector2(0.666f, 0.666f); | |
31 | UVs[19] = new Vector2(0.666f, 0.334f); | |
32 | // Right | |
33 | UVs[20] = new Vector2(0.667f, 0.334f); | |
34 | UVs[21] = new Vector2(0.667f, 0.666f); | |
35 | UVs[22] = new Vector2(1.0f, 0.666f); | |
36 | UVs[23] = new Vector2(1.0f, 0.334f); | |
37 | ||
38 | mesh.uv = UVs; | |
39 | } |