How to create accurate mesh from texture (like 2D sprites)

Unity Pro automatically creates an accurate mesh for 2d sprites that basically fits the non-clear pixels.

Look at this example:
http://cdn1.raywenderlich.com/wp-content/uploads/2014/01/sprite_mesh.png

Now Unitys 2d sprites have some overhead for me so I don’t want to use them directly. But I really want to know how I can create these accurate meshes. Is there already a script or algorithm out there?

(Please no discussions if I should use 2d sprites directly or not, thanks)

There is a lot of algorithms for finding contour of figure.
It can be

with optimisations.
Optimisation of contour(like mesh optimisation) - complicated theme.

If for you it’s a one-time solution, it is better to use square meshes or optimize meshes by hands in 3d editor.

Thanks for the links, very interesting! I’ll check them out later.

My current solution is to simply create a Sprite with Sprite.Create() and my texture, create a GameObject, add a SpriteRenderer to it and assign the Sprite. Then you can read the mesh data by calling UnityEditor.Sprites.DataUtility.GetSpriteMesh() and so on. Everything is done in code and I destroy the GameObject after reading the data.

Plain but it works…

Of course you’ll need the pro version for this feature.