Press Tab to cycle modes stops working

Avatar
  • updated

Image 926

When editing this polyline, the tab to cycle modes stops working. It get's stuck on the second option and won't continue. Makes editing stuff really hard. Please fix or let me know if it won't repro. Might be interference from something else in my setup.


The whole tab thing is a bit janky and could maybe be better done. How's adobe illustrator or inkscape do these complex poly edits? Could we just select a point and hit delete? Could we just click on the middle of a line to add a point?

While you're here, could we be able to multiselect points and move them together?

Reporting a bug? please specify Unity version:
6000.3.10f1
Reporting a bug? please specify Shapes version:
4.5.1
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Bryan Livingston

The Unity Line Renderer editor can do multi-select and delete points with the delete key, if you'd like another example of what's possible.

Avatar
Bryan Livingston

With the original bug, hitting tab about 10 times get's it to switch to the next mode. During some of those tab presses the snap distance field becomes focused at the top of the scene view.

Avatar
Bryan Livingston
Quote from Bryan Livingston

The Unity Line Renderer editor can do multi-select and delete points with the delete key, if you'd like another example of what's possible.

https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/Inspector/LineRendererToolModes.cs

Avatar
Bryan Livingston

The PolygonCollider2D editor can do mid line insert point really nicely, but can't do delete or multi-select as far as I can tell.

Avatar
Bryan Livingston

I went ahead and fixed it for my needs. It still has the tab problem but I'm not using the thickness/color mode. Feel free to use my changes if you want.

Summary of what changed in ScenePointEditor.cs:

Removed:
- The EditMode.AddRemovePoints enum value and its branch (the old per-point "+ / x" buttons +
extrapolated endpoint additions for open polylines).
- The "add/remove points" entry in the Tab-cycle label.
- The mode-cycle header now only fires when hasEditThicknessMode or hasEditColorMode is set; for a
plain Polygon (your use case), there are zero extra modes and the Tab cycle never engages.

Repurposed:
- hasAddRemoveMode no longer gates a Tab mode — it now gates the new add/remove behavior
(insert-on-edge + Delete + Ctrl+D). LineEditor/QuadEditor/TriangleEditor already set it false, so
their fixed-count constraint is preserved.

Added (in PositionHandles mode):

- Selection dots — every point gets a small clickable dot. Click selects only that one. Shift+click
toggles in/out of the multi-selection. Selected dots tint orange, unselected tint blue.
- Combined position handle — when 2+ points are selected, a single Handles.PositionHandle appears at
the centroid; dragging moves all selected points by the delta in world space. Single selection (or
none) falls back to per-point handles so click-and-drag without prior selection still works.
- Edge-hover insert — each frame, finds the closest edge to the cursor in GUI space (within ~12 px).
Draws a translucent green sphere ghost at the projected position. Click it to insert a new point
there, using the existing Lerp delegate so PolylinePoint thickness/color are interpolated correctly
between neighbors. New point becomes the selection. Endpoints get a small skip-zone so the dot handles
don't fight the ghost.
- Delete / Backspace — removes selected points, respecting minPoints (3 for closed polygon, 2 for open
polyline).
- Ctrl/Cmd + D — duplicates each selected point in place (inserts a copy after the original); the
duplicates become the new selection.
- Ctrl/Cmd + A — select all (free bonus, since all the plumbing was already there).

Preserved:
- The thickness and color Tab modes for polylines that opt in.
- All existing DoSceneHandles(...) overloads (Polyline, Vector2 list, Vector3 list, Vector3+Color
list).
- colorEnabledArray, positionEnabledArray, useFlatThicknessHandles, onValuesChanged.
- The GUIEditButton toggle from SceneEditGizmos.

For your project (Polygon-driven cakes, no thickness/color modes enabled), the Tab cycle has
effectively been removed — only Position mode exists, so the KeyCode.Tab handler bails out via
HasAnyExtraMode == false. The bug from the user-echo thread no longer applies.

The Shapes plugin file is now modified. Future Shapes updates would overwrite this — the file's top
comment block notes the changes for whoever updates next time.

https://gist.github.com/Bryan-Legend/e5e83c8501c1af667194f2316f892c14

Avatar
Bryan Livingston

I updated to 4.6 before making those changes.

Avatar
Bryan Livingston

I did some battle hardening on the Editor today.

https://gist.github.com/Bryan-Legend/1f7f7e952be7de913e6617ce2ae8deda


Here's a summary of today's changes to ScenePointEditor.cs, suitable for sending to Freya:

---

Several bugs in our rewrite required hardening that's worth knowing about even if you take a different approach:

1. ControlID stability for Handles.PositionHandle. When the count of position handles drawn per frame changes (e.g. only one drawn for the selected point vs.

one per point when nothing is selected), the IDs PositionHandle allocates internally shift, and Unity's hot control routes drags to the wrong index — drags

"grab the last point I was moving." Fix: always draw a position handle on every point when 0 or 1 are selected.

2. Conditional Handles.Button shifts subsequent IDs too. The edge-insert ghost button sat before the position handles in draw order; toggling it on/off as the

mouse moves was enough to break drags. Moved the ghost draw to after the position handles.

3. Ghost overlapping handle territory. When the mouse is on a position-handle arrow and an edge happens to run along that arrow (or pass under the dot), the

ghost rendered directly under the cursor and Handles.Button ate the click. Suppressed the ghost when the mouse is within ~60 px of any point, and entirely

suppressed it when 2+ points are selected (the centroid handle sits where the ghost would).

4. Selection at the event level. With position handles always drawn on every point, the dot's Handles.Button is occluded — shift-click selection toggling has to

be handled manually on MouseDown before any handle gets the event.

5. Drag-to-place on insert. Handles.Button only fires on click-release, so the ghost couldn't initiate a drag. Replaced with a manual control: on MouseDown we

insert the point, claim GUIUtility.hotControl, and process MouseDrag/MouseUp ourselves — projecting the cursor onto the shape's plane via

HandleUtility.GUIPointToWorldRay against new Plane(tf.forward, tf.position). The drag handler runs before the position-handles loop each frame so the selected

point's gizmo tracks the cursor with no 1-frame lag.

6. Editor grid snap. Inserted points (and the ongoing drag) snap to EditorSnapSettings.move when EditorSnapSettings.gridSnapEnabled is on. Note: gridSnapActive

is not a real property in Unity 6 — gridSnapEnabled is the one the Scene view's magnet toolbar toggle binds to.

7. Dirty + prefab override recording. Undo.RecordObject alone wasn't reliably persisting List content mutations: prefab-instance edits could silently lose

their overrides on save/reload. Added a MarkComponentChanged helper that calls EditorUtility.SetDirty and, for prefab instances,

PrefabUtility.RecordPrefabInstancePropertyModifications. Called at the end of DoSceneHandles when changed and from the async color-picker callback.


Two adjacent files in the project that aren't in the gist but are related:

- SceneEditGizmos.cs: relaxed DidCancelAction to allow Tool.Custom, so an active EditorTool overlay doesn't immediately exit edit mode.

Move/Rotate/Scale/Rect/Transform still cancel.

- A small EditorTool overlay file that adds an "Edit Points" tool to the Scene view toolbar when a Polygon or Polyline is selected (mirrors Unity's

PolygonCollider2D Edit Collider affordance). Activation flips a new ScenePointEditor.IsEditingPoints public static.