Hierarchy rearranges itself

In Unity 5, I started noticing that when I open a project, it’s hierarchy has been almost completely jumbled, the only thing I can rely on is parent/child relationships. This hasn’t been a problem for a while, as order in the hierarchy doesn’t matter unless you look for children by index.

Unity UI layers it’s elements based on it’s order in the hierarchy. Every time I open my project, my UI layering is completely ruined by the randomly jumbled hierarchy! Words cannot describe how frustrating this is.

I cannot report a bug that includes files from my project because I don’t own the project. This can be replicated in any Unity 5 project with a full enough hierarchy.

Bump

Please guys, vote for this bugfix: Unity Issue Tracker - [Hierarchy] Order is not saved when scene is reloaded/started

I’ve personally never noticed this and use Unity every day at work.

Well I assure you it happens, it’s reported by lots of people (check the issue tracker).

To top it off, I’ve discovered today that your hierarchy can rearrange itself when you enter play mode. I even tried saving the scene and project before hitting play, and I can sit there and hit play, stop, play, stop over and over and watch the hierarchy jumble back and forth between the order I gave it and the order it decided upon.

This is no longer a problem for me because I made a special script to save the hierarchy order at edit-time and force it at load-time. It was complicated and took me several hours and required a lot of editor scripting, which most users don’t know how to write. This is a really bad bug that needs to be fixed… I don’t see how those learning to program can possibly overcome this without awkward parenting, which in a way teaches them bad design habits.

Unity Issue Tracker - Hierarchy order of canvas children is not persistent (claims it’s fixed, but I can still reproduce in 5.1.3f)

I’m experiencing it too ever since upgrading to 5.2, had no problems with 5.1.

Same problem using 5.3.1.

They said it is fixed but it is not.

I don’t know if this helps given that I think there is more than one cause of this issue, but I saw this happen where an object refused to keep its position in hierarchy when you hit play. The object in question was a prefab. I discovered that when I broke the connection with the prefab for that object, it fixed the problem.

Good find, but it’s not always an acceptable solution when you need to keep 4 sections of UI using the same prefab, each with their own subtle changes and still have correct layering (like every split-screen game…)

In my scene it’s happening with objects that aren’t prefabs.

1 Like

Just noticed this happening with a UI panel with two children, an image and text. On play the two children change order so now the text is on top of the image. I’m forcing it with setaslastsibling() but this is just annoying.

Having this happen right now in 5.6 and it is killing me! Every time I hit play my Canvas hierarchy gets re-arranged!

From some quick debugging it looks like the Sibling Index is in fact changing, and I am not changing it, unless it is a knock on effect of something else. Thing is that it is already “wrong” at the time of Awake, so I don’t even see a way to work around it!

Actually I don’t even have to hit play. Just load the scene and it gets messed up!

Also noticing as pointed out by RV1 that if I break the prefabs, then the problem goes away. Not a real solution though for many reasons, not the least of which going through an entire UI and breaking all the prefabs is painful as you have to delete a child to break it then re-add that child.

Bingo! Prefabs aren’t properly serializing/deserializing!

I have a editor tool that I use to bulk apply properties to objects based on data loaded form JSON. I run this in the editor and it updates thing. Suddenly I noticed that they were losing those properties upon loading the scene or hitting play. On a whim, I broke the prefab and reloaded the properties and then bam they were persisting properly again. I bet this is why the sibling index is getting reset as well.

Does anyone know if this bug is fixed? My prefabs reorder in hierarchy when I press play. Is there any other workaround than disconnecting with the prefab?

This is still happening in 2019.3.0f6. Can’t believe it’s not solved yet. IT says solved in 5.x but not in 2019.x? https://issuetracker.unity3d.com/issues/hierarchy-order-is-not-saved-when-scene-is-reloaded-slash-started

1 Like

Also still happening in 2019.3.0f6 for me…

1 Like

I haven’t seen this issue in years, but I also haven’t used 2019.3.0f6. You guys should report a bug using [Help → Report a Bug] in Unity.

Still have this bug :frowning:
2019.2.21