fix: match tree order to unity hierarchy#151
Merged
Merged
Conversation
This was referenced Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Order the diff tree the way Unity's Hierarchy window does: siblings follow the parent Transform's
m_Childrenarray, and scene roots followSceneRoots.m_Roots(orm_RootOrderfor old scene formats) instead of YAML document order.Motivation
Unity serializes YAML documents in an order unrelated (often exactly reversed) to the Hierarchy.
core/src/tree.zigbuilt the tree in document order, so the editor window, CLI, and extension all showed objects in the wrong order — e.g. the Playground scene fixture rendered Floor → Crate → Sun while the Hierarchy shows Sun → Crate → Floor. One fix in core corrects all three surfaces.Closes #150
Changes
m_Childrenorder; PrefabInstance children rank via their stripped root Transform (reusingownerNodeIdOfTransform).SceneRoots.m_Roots(class 1660057539, after side preferred) when present, else stable-sort bym_RootOrder(PrefabInstance roots read it fromm_Modifications); prefabs and.assetfiles fall through untouched.modificationValuefrominstanceNamefor reuse.Testing
zig build test --summary all— 168/168 tests passed (the five new tests failed before the fix with reversed order, e.g.expected 2, found 3).pnpm test(extension) — 187/187 passed.dotnet test(editor DotNetTests~) — 34/34 passed.prefablens site/fixtures/{before,after}/Assets/Scenes/Playground.unitynow prints roots Sun → Crate → Floor, matchingSceneRoots.m_Roots(previously Floor → Crate → Sun).Robot.prefabdiff now prints Robot → Arm → Sensor, matching the root Transform'sm_Children(document order is Sensor → Arm).