Search Unity

2D Sprite mask with holes

Discussion in '2D' started by madclouds, Jan 10, 2016.

  1. madclouds

    madclouds

    Joined:
    Nov 6, 2013
    Posts:
    31
    I'm working on a game where level boundaries are generated from a grid. I'm able to create the boundaries using an EdgeCollider2d and setting their points.

    Now I'm looking for a way to mask the boundaries with an image. I've tried using the Triangulator code to generate a mesh and apply a Depth Mask material to it. This worked fairly well, but not with convex meshes or with holes which are essential to my game.

    How would you generating a sprite such as this:


    Thanks in advance!
     
  2. madclouds

    madclouds

    Joined:
    Nov 6, 2013
    Posts:
    31
    I got it working with Triangulator and the Depth Mask! The issue I was having was that I listed my vectors counter-clockwise and I needed to have them listed clockwise. Also, array of vectors should not have the same first and last point.

    Here's an example output: http://i.imgur.com/IzLHnxn.png