Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
1
Question by Olivier-Tache · Sep 29, 2015 at 11:58 AM · runtimehierarchyorder

Why does hierarchy order change at runtime?

Hi,

I've recently begun working on a Unity project that was started by someone else.

I noticed that some top-level GameObjects have a different order in the hierarchy when the project is running in the Editor and when it's not. I don't understand why.

I can't find any call to transform.SetSiblingIndex in the project's code. What other mechanics could explain this ?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Kyle_WG · Sep 29, 2015 at 12:34 PM

Any instantiated objects may cause the hierarchy to change, especially if unparented.

The hierarchy order shouldn't be an issue anyway. If you're relying on the order consider using a container object instead and parent objects you need to that. Then you can get access to the children from that transform. Or even hold the instantiated object's references in an array or generic container instead. Relying on Unity's hierarchy order is bad practice and should be avoided.

Comment
Add comment · Show 2 · 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 Olivier-Tache · Sep 29, 2015 at 02:19 PM 0
Share

Thanks for your reply @$$anonymous$$yle_WG. Actually, I do not use the order of the objects, it would just be more practical for me that these objects do not move when i want to inspect them at runtime, since I have to remember two positions in the hierarchy ins$$anonymous$$d of one.

Any instantiated objects may cause the hierarchy to change, especially if unparented.

Do you mean that instantiating/parenting/unparenting can affect any part of the hierarchy, even in a branch that is not concerned by those operations ?

avatar image Kyle_WG Olivier-Tache · Sep 29, 2015 at 03:50 PM 1
Share

The hierarchy is sorted using some internal methods. Check this link on BaseSorting if it helps you. It'll sort itself when the Hierarchy becomes dirty through parenting / instantiating. If an object becomes unparented for example it'll have to change sort order on the top level objects (the main parents).

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Unity is displaying UI elements behind background image 2 Answers

Export objects to a .3DS file at runtime 1 Answer

How to retrieve current shown hierarchy? 2 Answers

Objects not updating if not selected in Hierarchy? 0 Answers

Spawn objects (Instantiate) behind hierarchy 1 Answer


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