Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by diegzumillo · Nov 29, 2013 at 06:02 AM · editorpolygon collider 2dmesh verticesmesh manipulation

Create mesh by defining points

I want to create an editor script that allows me to create a mesh. This isn't a complicated 3d mesh creation I'm looking for, I want to use them on a 2d game, to serve as visual representation of platforms and walls etc.

Right now I can make an editor script that allows me to create a polygon collider 2d by clicking and defining points. This is quite easy because polygoncollider2d has useful functions to create colliders. But I need an actual mesh, a set of polygons, to create a visual representation of this collider.

I read about the mesh component and figured how to create meshes. But I'm completely stumped in creating an algorithm that generates concave polygons by simply defining a set of ordered points, similarly to the way PolygonCollider2D.SetPath() works.

I didn't get much help from theforums, so I decided to try here :)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Eric5h5 · Nov 30, 2013 at 07:26 PM

http://wiki.unity3d.com/index.php?title=Triangulator

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image diegzumillo · Nov 30, 2013 at 09:10 PM 0
Share

Triangulator! I knew there had to be a keyword I was missing from my googling. Thanks a bunch, this is exactly what I need :) I mean, probably, I'm still checking it out, but the first tests are looking promising.

avatar image komodor · Dec 01, 2013 at 09:31 AM 0
Share

actually this is very helpful for me too, thanks!

avatar image Ariopolis · Feb 12, 2016 at 04:48 AM 0
Share

This looks like what I have been looking for, too. Thank you!

avatar image
2

Answer by komodor · Nov 30, 2013 at 03:50 PM

here you go mister: http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html

so basically you create mesh, and arrays with vertices, then you group them in array triangles (the array is 3 times longer then the vertices array)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image diegzumillo · Nov 30, 2013 at 07:01 PM 1
Share

Hello :) As I said in the question, I read about the mesh component and I know how to create a mesh. I need an algorithm that takes a set of ordered points and creates the full mesh. There's a big difference between taking three vertices and making a triangle and taking 23 vertices and X triangles and creating them depending on the order of points. I don't know how to detect consistent shapes that can be made and stuff like that

avatar image
0

Answer by BenWiller1989 · Sep 03, 2020 at 07:14 PM

It might be obsolete, but for any other people with an issue like that: I try the same with an CustomEditor script (just for fun for now) . I thought about using an origin object (or the middle of all point) , to use it for every second point of a triangle. But it would have to be in the center for it, to be consistent and nicely shaped. So if you have a Centerpoint and place new point around it (best viewed by some Handles) and after at least three points, click a butten, to create a mesh, it would take point[0] as the first, the center as the second, and point[1] as the third point, for the first triangle. For the second triangle it would take point[1] as the first, the center as the second and point[2] as the third point. And so on.... You get the idea.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Generating Vector3s with Perlin Noise? 1 Answer

GameDraw can't edit meshes 0 Answers

Polybrush on runtime 0 Answers

Is it possible to detect changes to a different component within an editor script? 0 Answers

Set prefab to public variable of another script 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges