void BuildTexture() { // get Data TileMap mapData = new TileMapData(size_x, size_y); int texWidth = size_x*tileResolution; int texHeight = size_y*tileResolution; // object for our texture Texture2D texture = new Texture2D(texWidth,texHeight); // stores texture of tiles Color[][] tiles = ChopUpTiles(); // set texture for one tile for (int y = 0; y < size_y; y++) { for(int x = 0; x < size_x; x++){ Color[] p = tiles[mapData.GetTileID(x,y)]; texture.SetPixels(x*tileResolution, y*tileResolution, tileResolution, tileResolution, p); } } texture.filterMode = FilterMode.Point; texture.wrapMode = TextureWrapMode.Clamp; // Apply pixel to texture texture.Apply(); MeshRenderer mesh_renderer = GetComponent<MeshRenderer>(); mesh_renderer.sharedMaterials[0].mainTexture = texture; // Debug.Log("Done Texture!"); }