Skip to content

Set pivot: keep the mesh in place in other scenes and prefabs - #319

Merged
rixnobis merged 3 commits into
mainfrom
pivot-other-scenes
Nov 3, 2026
Merged

rixnobis merged 3 commits into
mainfrom
pivot-other-scenes

Conversation

@rixnobis

@rixnobis rixnobis commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Closes #316. Set pivot now also moves every object that draws the mesh in the project's other .scene and .prefab files, so nothing shifts when they are opened later. Those files change in the same undo step as the open scene, and undo restores their bytes. Files without such an object keep their bytes and timestamp. An unreadable scene or prefab stops the whole operation with nothing changed; the error message names that file. Unity YAML prefabs in the project are skipped.

Set pivot now works on prefab instances: it compensates the instance's transform and rewrites the prefab file. With a prefab open for editing, it refuses if the scene behind it draws the mesh. Loading and re-saving the 15 repo and sample scenes loses nothing: 7 come back identical and 8 gain only keys at the loader's defaults. Tests: testSetPivotOtherFiles, testSetPivotBrokenFile, testSetPivotPrefabMode (editor_tests 11795).

Every scene and prefab file of the project holding an object that draws
the pivoted mesh is rewritten with the same compensation as the open
scene (the object moves onto the new pivot, its children back by it),
through a FileSwapsCommand in the same undo step, so one undo puts every
file back byte for byte. Files that do not draw the mesh are not written.
All files are worked out before anything is written; one that cannot be
read or written stops the whole operation with an error naming it.

Prefab instances in the open scene are no longer refused: an instance
whose prefab's root draws the mesh moves where it is placed, and its
content comes from the rewritten prefab file. In prefab mode, a scene or
prefab waiting behind the open prefab that draws the mesh refuses, since
it is held in memory.

reimportWithSettings' sceneFirst can now return an error to stop.
testSetPivotOtherFiles: the cube drawn in the open scene, in another
scene directly and through instances, at a prefab's root and deeper in
another prefab; after Bottom centre every world vertex is unchanged in
every file, undo restores every file byte for byte, and a scene without
the mesh is never written. testSetPivotBrokenFile: an unreadable scene or
prefab stops it, nothing changed. testSetPivotPrefabMode: refused when the
scene behind the open prefab draws the mesh, done when it does not.
@rixnobis
rixnobis merged commit 10b991f into main Nov 3, 2026
5 checks passed
@rixnobis
rixnobis deleted the pivot-other-scenes branch November 3, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set pivot does not compensate the mesh's instances in other scenes or prefabs

1 participant