Exemplo n.º 1
0
    private void UpdateUVs()
    {
        int numVertices = (m_width) * (m_height) * 4;

        Vector2[] uvs = new Vector2[numVertices];

        if (SourceChunk != null)
        {
            for (int j = 0; j < m_height; ++j)
            {
                for (int i = 0; i < m_width; ++i)
                {
                    TileInfo tileInfo    = m_sourceChunk.ReadSlotValue(i, j);
                    int      vertexIndex = (j * m_width + i) * 4;
                    TileMapping.GetUVFromTile(tileInfo, out uvs[vertexIndex], out uvs[vertexIndex + 1], out uvs[vertexIndex + 2], out uvs[vertexIndex + 3]);
                }
            }
        }

        MeshFilter mf = GetComponent <MeshFilter>();

        mf.mesh.uv = uvs;

        m_dirty = false;
    }