public override void CreateQuad(Cubeside side) { string textureName; switch (side) { case Cubeside.TOP: { textureName = textureNames[0]; break; } case Cubeside.BOTTOM: { textureName = textureNames[1]; break; } default: { textureName = textureNames[2]; break; } } QuadMesh quadMesh = new QuadMesh(side); TextureAtlasMapper mapper = Game.currentGame.mapper; Vector2[] uvs = mapper.GetMappedUVs(textureName); GameObject quad = new GameObject("Quad"); quad.transform.position = globalPosition; quad.transform.parent = chunk.GameObject.transform; MeshFilter meshFilter = (MeshFilter)quad.AddComponent(typeof(MeshFilter)); Mesh myMesh = quadMesh.mesh; myMesh.uv = uvs; myMesh.RecalculateBounds(); myMesh.name = "my mesh"; meshFilter.mesh = myMesh; MeshRenderer renderer = quad.AddComponent(typeof(MeshRenderer)) as MeshRenderer; }
public virtual void CreateQuad(Cubeside side) { string[] textures = new String[6]; if (textureNames.Length == 1) { for (int j = 0; j < 6; j++) { textures[j] = textureNames[0]; } } else { textures = textureNames; } for (int i = 0; i < textures.Length; i++) { QuadMesh quadMesh = new QuadMesh(side); TextureAtlasMapper mapper = Game.currentGame.mapper; Vector2[] uvs = mapper.GetMappedUVs(textures[i]); GameObject quad = new GameObject("Quad"); quad.transform.position = globalPosition; quad.transform.parent = chunk.GameObject.transform; MeshFilter meshFilter = (MeshFilter)quad.AddComponent(typeof(MeshFilter)); Mesh myMesh = quadMesh.mesh; myMesh.uv = uvs; myMesh.RecalculateBounds(); myMesh.name = "my mesh"; meshFilter.mesh = myMesh; hasCubeSideMesh[side] = true; } }