Prefab Variants erroneously rearrange the order of GameObjects in their hierarchy

2018.4.10 LTS

Hi all. I’m encountering a problem where the order of GameObjects in a base prefab’s hierarchy is being rearranged in its variants. I’ve attached an image showing a simple example. Being variants, it’s not possible to correct this.

5094392--502031--PrefabVariantOrdering.png

This has completely broken our UI in particular, as now sprites are being drawn in the wrong order. It’s rendered some screens unusuable. The only workaround I can see is to unpack these variants, thereby losing the benefits of the nested prefab workflow, which has been very good up until now.

Is there a way to restore the order of GameObjects in a variant to that of its base? Many thanks.

Same thing happens to me, I’m not sure why this is happening.

It probably is worthy of a bug-report. Unless it already is reported.

After some testing, a not-ideal fix is just to revert all changes to the affected prefab variant. (From the top part in the inspector, Overrides → Revert All) You lose all your overrides, but the hierarchy order corrects itself in the process.

Edit: You can fix the order of individual GameObjects, but inconsistently. You just need to select individual RectTransforms from the Overrides dropdown menu and revert changes to those. We’re having inconsistent results by doing this; the order of GameObjects is sometimes being changed, not always, and not necessarily to the correct order of the base prefab.

1 Like

I’ve just run into this issue in 2019.2.2. Is there an offical bug for this yet and/or any recognition from Unity that this problem exists?

This fixes the issue.

You can also open the prefab file in a text editor and manually change the m_RootOrder value of the objects.

The hard part is finding the correct objects in the file, but it’s better than the “Revert All” because it doesn’t revert everything.

1 Like

I also encountered this error. On my prefab, I also had one added, but not applied object. I applied it to the prefab, and order change started to work as expected.

Prefab overrides are at the end of the file, so it is enough to delete the lines with