• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
8
Question by gdwf · Mar 18, 2016 at 12:47 PM · guieditorhierarchy

Objects in hearachy change order for no reason

This is particularly bad when you are working with GUI because the order of the hierarchy is so importance there. I am implementing a menu system with blades that stack on top of each other.

It happens to me every now and then in my main menu scene, all of a sudden when I press the play button a few random objects will shuffle in the hierarchy and I have never been able to figure out why that happens. I have tried everything to figure out the cause: removing all animations and even disabling every single object in the scene and still those same objects will change their position in the hierarchy as soon as hit the play button (or reload the scene).

I can even reproduce this without pressing the play button:

  1. I would start unity.

  2. Load my project.

  3. Open the scene.

  4. Arrange the hierarchy in the order that things need to be.

  5. Save the scene and Save the project

  6. Close unity.

  7. Then when I reopen my scene back up after all that: objects in the hierarchy are in a different/wrong order.

The only workaround I have found so far is to try to figure out which objects are the ones getting moved around, duplicating them, deleting the originals and fixing all the broken references. This is not a scale-able once your menus start becoming more complex.

Does anyone know an actual cause or solution to this problem? Reinstalling unity did not help :(

Here is an example of what I am seeing:

alt text

example.jpg (110.6 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Plattinator · Oct 29, 2016 at 02:32 AM 1
Share

I just ran into this problem also, and it was after replacing existing game objects with a prefab by alt+dragging the prefab from the project onto the game object in the hierarchy. The replaced objects would get their order reset to be the first child when entering/exiting play mode or reloading the scene. Luckily there were only a few and the workaround mentioned of deleting the original and replacing it worked for those. Still a very annoying problem.

avatar image Fattie · Sep 07, 2020 at 04:37 PM 0
Share

a typical INSANE unity bug. madness.

7 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by porters · Jun 09, 2017 at 05:17 PM

@gdwf I've been experiencing the same issue. I believe it could be related to one or both of the following:

  1. gameobjects with names that contain the "_" character - generally preceding other text i.e. _myObject

  2. nested prefabs

I have been getting around this issue with a simple script workaround. If you find a better solution then please let me know. The script I am using is below - it simply sets the sibling index of the transform the script is attached to. The script runs at design and runtime so your transforms should stay ordered how you want them all the time.

Hope this helps

  [ExecuteInEditMode()]
     public class SiblingIndex : MonoBehaviour
     {        
         public int index;
 
         private void Awake()
         {    
             transform.SetSiblingIndex(index);
         }
 
     }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by misher · May 04, 2020 at 03:50 PM

For me it was a prefab related issues. The solution was simple enough. In scene, break a prefab, change the order, drag on the prefab asset again to overwrite it with new version. Works with prefab variants as well.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by HonoraryBob · May 09, 2018 at 02:37 AM

@gdfw This happened to me when I was using a prefabbed set of UI elements - i.e. one group had been saved once as a prefab, and so whenever I hit Play it would revert to the prefab's original form since I hadn't saved the new version to that prefab. I solved it just by breaking the prefab connection by moving one gameobject out of the group and then moving it back in.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Pangamini · Aug 19, 2019 at 04:26 PM 0
Share

This is still happening in 2019.1.14f. Did you manage to solve this non-destructively?

avatar image
1

Answer by cmann · Dec 13, 2019 at 09:12 PM

It seems like an issue with prefabs. Not always ideal, but another solution is to wrap the prefab in a regular gameobject, which will preserve its order.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by WheresMommy · Dec 14, 2019 at 06:27 AM

Did you try to put your whole Canvas in a prefab with your current prefabs in it?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cmann · Dec 16, 2019 at 09:27 AM 0
Share

Yes, but it didn't help.

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Cant hide anything in Hierarchy IDE 2 Answers

Hierarchy in editor 2 Answers

The Unity GUI skews itself when not centered on the screen and in build mode 0 Answers

Editor Scripting Input Problem OnGUI() 1 Answer

Unity Preferences' Large Heading Font 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges