Get mesh vertex colors

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 " + Selection.activeTransform.gameObject.name);
		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){
			if(!colors.Contains(c)){
				colors[i] = c;
				i++;
			}
        }

		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);
	}
}

C9McEc-U0AAKSZt

C9McIvWVYAAY3f1

Active Nav for 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.

sprInvoice for WordPress

My sprInvoice template was released some time ago, and a WordPress version has just been released.

Create quick, clean, and easy to use and print invoices from right within WordPress with sprInvoice. With multiple line items, a responsive design, and a no-frills implementation sprInvoice is easiest and most simple invoice solution for WordPress.

Grab it on WordPress.org.

sprInvoice Updated

It only took a year and a half, but thanks to numerous comments, tweets, and emails, I’ve finally updated the sprInvoice Template with a print style. It also might have been the upcoming WordPress plugin that uses it influencing my time in that direction.

Enjoy.