This might not be the most elegant solution, but it might work for you:
- Define that shape as a PolygonCollider
- Get the bounding box of that collider (
- Generate a random point in that bounding box, check if it is in the PolygonCollider (
PolygonCollider.OverlapPoint(Vector2 point)), and if not repeat
Drawback: Should the polygon for some reason have an area of zero, you will run into an infinite loop. It can even become a performance bottleneck when the area is just very small compared to the area of the bounding box. You can mitigate that problem by limiting the maximum number of tries, but then you no longer have a guarantee that every spawn will be successful.