Enumeration of asset's colours, imported from MagicaVoxel .obj

Hi, I’m trying to programmatically enumerate the 3 colours used in a simple .obj asset I imported from MagicaVoxel but am not yielding any sensible results.

I wondered if I could persuade someone to slap a brief example together to show me how, tested against the attached files? I could really use the help, chr

5053349–495848–ship vox and obj.zip (4.88 KB)

In case anyone is interested, here’s some sample code, the key being to ensure you enable read/write on the .png palette generated alongside the .obj file exported by MagicaVoxel:

MeshRenderer mr = this.go.GetComponentInChildren<MeshRenderer>();
MeshFilter mf = this.go.GetComponentInChildren<MeshFilter>();
Vector2[] uv = mf.mesh.uv;
Texture2D t2d = (Texture2D)mr.material.mainTexture;

// iterate the uv
for (int i = 0; i < uv.Length; i++)
{
    Vector2 v2 = uv[i];
    int ix = (int)(v2.x * t2d.width);
    int iy = (int)(v2.y * t2d.height);

    ...
}