- Home /
How to directly edit a Polygon Collider2D's points in the inspector?
I'm trying to make a polygon collider as a shaped range-detect for a turret. I've found that manually dragging the points around is rather inaccurate. If I could manually change the points array in the Inspector, I could make a fairly symmetrical shape.
Setting the points at runtime would probably be far more difficult than in the inspector (as far as making the shape without being able to see it), and I would be unable to see the shape till the game is ran :/
Answer by Farresto · Jul 11, 2018 at 11:44 PM
It's a little old, but perhaps someone else is looking for this.
If you unselect the EDIT COLLIDER button, you can manually enter any values you need in the inspector (the values of X, Y in the Element Array).
Yes this works!
But only if you have the editor in Debug mode, opposed to normal mode.
in the inspector, go to top left corner settings -> debug
This answer is correct. The above comment is incorrect--you do NOT need the inspector in debug to do this.
Answer by Sisso · Sep 22, 2015 at 12:20 PM
The polygon points are accessible by script.
http://docs.unity3d.com/ScriptReference/PolygonCollider2D.html
But unfurtunally you have to write your own code (or find an already build) to edit it. It is up to you how do you want to update it (directly script, menucontext, editorwindow, custom inspector, etc)
http://docs.unity3d.com/Manual/ExtendingTheEditor.html
I found this:
http://stackoverflow.com/questions/29819697/manually-edit-unity3d-collider-coordinates