Get mesh vertex colors

April 12, 2017 - posted in Code, Unity, VThree

I use Probuilder & Polybrush with vertex colors for all the art in VThree. Keeping track of all the colors can be a chore, and if I lose one figuring out which it is visually is impossible. So I whipped this up quickly this evening. It’ll print all the colors on your mesh (if you’re using vertex colors) to the console.

Right click on an object in the hierarchy and choose “Get Vertex Colors”

Hopefully useful for someone.

using System;
using System.Linq;
using UnityEngine;
using UnityEditor;

public class NWZGetMeshColors : MonoBehaviour {
    [MenuItem("GameObject/Get Vertex Colors", false, 0)]
	private static void GetVertexColors(){
		Debug.Log("Getting mesh colors for " +;
		Mesh mesh = Selection.activeTransform.gameObject.GetComponent<MeshFilter>().sharedMesh;
        Vector3[] vertices = mesh.vertices;
		Color[] colors = new Color[vertices.Length];
		int i = 0;

		foreach (Color c in mesh.colors){
				colors[i] = c;

		Color[] uniqueColors = new Color[i];
		Array.Copy(colors, uniqueColors, uniqueColors.Length);

		foreach (Color c in uniqueColors){
			Debug.Log("<color=" + ToRGBHex(c) + ">▉</color> " + ToRGBHex(c));

	public static string ToRGBHex(Color c){
		return string.Format("#{0:X2}{1:X2}{2:X2}", ToByte(c.r), ToByte(c.g), ToByte(c.b));
	private static byte ToByte(float f){
		f = Mathf.Clamp01(f);
		return (byte)(f * 255);



Active Nav for Meteor

August 20, 2015 - posted in Code, HTML & CSS, Meteor

I prototype on Meteor even when it’s not necessarily the framework that will be used in the final production, and I’ve found myself writing active states for the nav into the router each time.

That’s a huge waste of time, so on this latest prototype I made a quick Active Nav package for Meteor. Just import the package, specify which element your nav is made of, and go.