UnityPatterns PolyMesh 2D Example
Unity’s a great game framework with a rich community full of generous folk who share some of their tools in the form of Unity assets/plugins. One such contributor over at unitypatterns.com share some excellent goodies to facilitate 2D game dev. PolyMesh is an editor extension that allows the user to rapidly build 2D meshes, containing both curves and straight lines, right in the Unity GUI. Creating a collider that follows a mesh’s edge is handled with a single click.
Here’s a sample of a mesh with a UnityPatterns demo texture and an automatic collider.
You would however feel quite disappointed if you’ve configured Unity to use the 2D physics system, which renders this automatic 3D collider useless. To create the 2D collider, you must make a simple modification to the PolyMesh.cs:
// replace MeshCollider with 2D version
// public MeshCollider meshCollider;
public PolygonCollider2D meshCollider;
// replace UpdateCollider function with
void UpdateCollider(List points, int tris)
if (meshCollider != null)
Vector2 points2D = new Vector2[points.Count];
for (int i = 0; i < points.Count; i++)
points2D[i] = new Vector2(points[i].x, points[i].y);
meshCollider.points = points2D;
Creating a collider with the modified code gives us a physics collider object that will now interact with a 2D physics setup.
PolyMesh makes creating 2D platforms and large texture areas a doddle, even if it’s just for prototyping.