- Home /
Draggable Nodes in Editor?
For my 2D physics engine implementation in Unity, I'd like to have editable colliders. In the inspector, the user can access the collider vertices' positions but I'm hoping he or she could also change the positions of the vertices by dragging. Is there some way I can put a node on each vertex the user can drag around? I'd need to assign this node to a specific value in the collider script.
Answer by incorrect · Feb 09, 2015 at 04:06 AM
Sure you can do it.
The BoxCollider2D can be defined by it's center and Vector2 size, so by dragging some controlls you can modify those values.
The CircleCollider2D has center and radius, they also can be modified.
Working with PolygonCollider2D can be a bit tricky because you have to check if the shape of a collider is convex, and if it's not you have to break it in several paths, each being convex polygon.
I have my own colliders and I need to edit the positions of the vertices by dragging them.
public List<Vector2> Vertices;
They're just a lists of Vector2's. I need to be able to modify them in the editor with dragging.