Any script to 'fix' normals/winding order?

I was wondering if anyone knows of an editor script which would go through a mesh and compare the normal direction(s) to the triangle vertex winding order, and fix them to match? Reason is, I got some crazy models from sketchup and I know the verts and tris are there, but some face the wrong way. So I wanna run like a sanity-check on them, either flip the order, or flip the normals. Probably flip the order, cuz I think the normals are correct.

This will flip the triangles. I’ll leave it to you to pick one and compare the normals and fix them they way you want.

@MenuItem("GameObject/Flip Mesh", false, 4) 
static function FlipMesh() 
{ 
	Undo.RegisterSceneUndo ("Flip Mesh");
	var trs = Selection.GetTransforms (SelectionMode.Deep);
	for (var tr in trs) 
	{
		var r : MeshFilter = tr.gameObject.GetComponent.<MeshFilter>();
		if (r)
		{
			var m : Mesh = r.sharedMesh;
			if (m)
			{
				var tris : int[] = m.triangles;
				for (var i : int = 0; i< tris.Length; i+= 3)
				{
					var t : int = tris*;*

_ tris = tris[i+1];_
* tris[i+1] = t;*
* }*
* m.triangles = tris;*
* }*
* }*
* }*
}

  1. it’s not easy for script to detect right face direct automatically
  2. ‘calculate normals’ in import settings for model can fix problem with incorrect normals.

Here is one of possible solutions