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 ?
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.