I am making a 2D stealth game. The player has a view cone that shows the players lines of sight. Currently the view cone is a mesh rendered infront of 2D sprites in a 2D game. I am trying to use a sprite mask to hide enemies when they are not in the players line of sight.
I tried using a sprite mask for this but the sprite mask component requires a sprite while I have a mesh. Sprite Mask Component
I want the red square to only be visible while behind the yellow fov cone.
The fov mesh is calculated at runtime with raycasts and constructed from the hit points of those casts.
Is there a way to convert the mesh into a sprite to use with a sprite mask?