0
\$\begingroup\$

I want to procedurally create a polygonal shape filled with texture in unity 2d (no 3d meshes). Something that looks like this: https://www.conceptdraw.com/How-To-Guide/picture/landscape-plan/Building-Plans-Landscape-Garden-Design-Elements-Roofs.png

As you can see roofs can be rectangles, but also any polygonal shapes.

Can it be done in vanilla unity 2d? Or should I rely on 3rd party libraries and if so which one would fit best?

p.s. I will most likely overlay that object with PolygonCollider2d for physics

\$\endgroup\$
  • \$\begingroup\$ We have a question about dynamically creating textured polygons here. The answer shows shaping the polygon in the editor, but you could use the same script (or similar method) and pass it a list of vertices you've chosen procedurally just as well. \$\endgroup\$ – DMGregory Feb 23 at 5:33
  • \$\begingroup\$ @DMGregory that one is 3d mesh, my question is for 2d only \$\endgroup\$ – Zepplock Feb 23 at 21:16
  • \$\begingroup\$ Hint: 2D sprites are actually drawn as 3D meshes anyway. ;) \$\endgroup\$ – DMGregory Feb 23 at 21:40
  • \$\begingroup\$ Im aware of that ;) My question was more around unity engine best practices. I ended up doing mesh for now. I might change it to something else once I need to texture it better. \$\endgroup\$ – Zepplock Feb 26 at 16:47
1
\$\begingroup\$

Sprite shapes

They allow you to create adbitary polygons filled in with sprites. You can also make the edges different based on the angle.

They've been built into Unity for a a year or so.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.