Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity 4.5 New Hierarchy Window sorting

Discussion in 'Editor & General Support' started by Ben-BearFish, May 27, 2014.

  1. meat5000

    meat5000

    Joined:
    Mar 5, 2013
    Posts:
    118
    Installed 4.5.1 hoping for an improvement on this. Now the Alpha Ordering script no longer works properly either :/ It sorts vaguely then gives up. Don't really have time to mess around with this; too much work to be getting on with!

    Edit: My bad; just noticed the #if 4.5 directive.

    Removed, now its fine again :)
     
    Last edited: Jun 20, 2014
  2. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Any changes or fixes with this problem ? Unity please My project is in totaly chaos without old sorting ....
     
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    I don't mind this change, but there isn't any option to toggle it off which is kind of annoying even though its probably functionally better to work as it is now there should be some function somewhere to sort by name. Changing the sorting doesn't persist through a play, and thats kind of annoying too.

    Bottom line it just needs to be extended with some more features as there isn't much control over the jibberish that is now the hierarchy.
     
  4. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    I heard UT brought in some crack programmers to address this issue quickly. Ironicly they are Ents. ;)
     
  5. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    To a degree it has been fixed on UT side. Just that by the time I received the bug, resolved the bug, got it approved 4.5.1 was already in the process of shipping so it wasn't going to make the cut off.
     
  6. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Could you please submit a bug. I've opened many scenes both from 4.3 into 4.5 and 4.5 and ran and everything everyone is describing here with no luck reproing the issue. and noone has submitted a bug about it that i've found.

    Thanks,
     
  7. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    Unfortunately I tried to replicate it but I can't on other projects. I'd have to clean mine pretty heavily before sharing it, but I'll see what I can do. Either way, thanks for letting us know you're on top of it!
     
  8. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Even if you could give me some more details as to what you have in your project and what is moving around. i.e.
    prefabs
    • how big are they
    • are they nested deep under normal objects,
    project itself
    • was it a project from 4.3 moved to 4.5
    • 2d or 3d
    • large or small
    • window layout (dont think it should matter but who knows!)
    Sanity check that you are saving the scene after moving the object around.

    Really anything with any sort of details might allow me to work towards a solution. Even if you can share your project with just me that'd be great but i would understand any hesitance with sharing you work.
     
  9. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    I don't even know how to call it ... I'm beyond frustrated.
     
    outtoplay likes this.
  10. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Got that, Phil?
     
  11. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Yup so it seems like a problem with prefabs :(.
     
  12. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    No, it happens to all objects. Even with those that was disabled. But only if they were moved in the hierarchy after loading the project. Saving scene does not help.
    In any case, there should be two hierarchy window. NOT SWITCHING! One for order in GUI and the other one (alphabetic) for scene. And add button to lock/unlock "parenting", or change how it works now. I suggest to make it like this: Drag & drop - can reparent, Ctrl + Drag & drop moves without reparenting. Or Ctrl + Mouse scroll.
     
    Last edited: Jun 23, 2014
  13. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Interesting. From your video i was able to find a issue with prefab serialization of root level prefabs. That has now been fixed and hopefully will get int 4.5.2.

    If there is a issue with moving objects in the hierarchy after loading a project please submit a project that i can repo that on. I have yet to find a instance where it breaks for normal objects. If your concerned about the size if you could give me repo access and PM or e-mail me the login information i can fix it against a broken project.

    Well you can have 2 hierarchy windows open if you like nothing is stopping you. To have yet another window just to support GUI did not make sense in our minds so we created the drop down method. Hopefully in 4.5.2 as well there will be a option to have the alphabetical sort as a default in the drop down. The drag and drop usability will hopefully be updated in a future release.
     
  14. orionburcham

    orionburcham

    Joined:
    Jan 31, 2010
    Posts:
    488
    Could this index be used as a reliable Transform GUID between saved games? I understand you're talking here about saving indeces for child Transforms (of other Transforms in a scene). I assume you're also doing this for the scene root, but that array may not be exposed.

    Then again, maybe you're just referring to the existing "Transform.GetChild()" method, and I've imagined your quote is about something new.

    Having a reliable GO or Transform GUID would be great, so my interest was piqued. But maybe I'm imagining things.
     
    Last edited: Jun 25, 2014
  15. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Unfortunately at runtime we have no such list of scene root objects. So we have nothing to expose :(.

    The new API that Leo was talking about is Transform.SetSiblingIndex() Transform.GetSiblingIndex(), Transform.SetAsFirstSibling(), Transform.SetAsLastSibling()
     
  16. RV1

    RV1

    Joined:
    Nov 18, 2012
    Posts:
    68
    Hi, theres a couple of issues I would like clarification on.

    1. Like other people, I'm experiencing issues where my reordering of transforms in the editor are not being saved. For example I modify the order in the hierarchy, but when I run the game the order reverts back to what it was before I changed it and stays reverted once I stop the game. Strangely this issue doesn't happen on all transforms though, but most seem to stubbornly refuse to have their order changed. It doesn't appear to be based on whether the transform is a prefab or not.

    2. I have noticed when I instantiate game objects at runtime, some game objects are inserted at the start of the hierarchy and others at the end. Although the insertion at start vs end appears to be deterministic, I have no clue as to what logic is deciding where a new object gets inserted. Can anyone clarify this for me?

    Thanks,
    RV
     
  17. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    I've also noticed that this tends to happen mostly with prefabs but not only... Some of my game objects have names started by underscore but also not sure if that influences it or not.
     
  18. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    1. Are you moving prefabs at the same time as moving non prefab objects when you see the non prefab objects no show up in the correct order? I have yet to see non prefab objects move if only the non prefab object was moved.

    This issue should also be fixed for the next public release. I'm in the process of getting it into the release branch.

    2. New objects *should* only be inserted at the end. But if i could get some more information from you i can try to reproduce it to see if its a bug.

    a) where are you instantiating the objects? Root level (i.e. no parent) or as a child of something
    b) what are you instantiating, prefabs, regular gameobjects, primitives?


    I really beleive that the issue stems from the prefabs. How the information is stored is just by a index. If a prefab were to end up in the wrong location it could possibly cause non prefab objects to end up in the wrong location as well.
     
  19. RV1

    RV1

    Joined:
    Nov 18, 2012
    Posts:
    68

    1. I'm definitely seeing the order of non-prefabs not being preserved. However, I'm wondering if it has something to do with prefabs that share an ancestor that are causing the issue indirectly. In an example I just tried it looks like this:

    A > at root level, not a prefab
    -B > not a prefab
    --C > not a prefab
    --D > not a prefab
    -E > prefab

    If i swap C & D around, then run the game the ordering change I made is undone.


    2. I have investigated further and believe I have found a pattern. These cases are with objects created at root level.

    - If a game object is created with new GameObject, then it gets inserted last.
    - If a game object is created with UnityEngine.Object.Instantiate(some_prefab) then it gets inserted first.

    I'm not 100% sure this is always the case, but so far it seems that way when I went through and checked every gameobject instantiated at run time.

    Regards,
    RV
     
  20. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    1. Hmm just created a hierarchy exactly how you described and both in 4.5.1 (current public version) and my current internal build i was not able to reproduce the issues. :( You possibly able to send me your project or a project so i can test against a broken one?

    2. That sounds about right. Not right as in correct behaviour but right as in i think i know what the issue is. :) Thanks!
     
  21. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    @phil, not sure if you're still wanting repro cases, but see Case 615622 that I submitted yesterday (for something else). To reproduce take the object 'GameObject' that is a sibling of prefab instances Test1, Test2 and Test3, and drag it between Test2 and Test3. Enter play mode and see how the order of all 4 gets rearranged and remain that way after exiting play mode.
     
  22. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Ah a test case finally :). Thank you i've been able to repo it on that project. Interesting enough not sure why i couldnt with mine :(. now to find the cause.

    Interestingly enough, the bug that you actually reported i can't reproduce (at least with the latest)...
     
  23. BenAdams

    BenAdams

    Joined:
    Jan 16, 2014
    Posts:
    1
    Alphanumeric sorting is an absolute must as projects grow larger and more complex. With a quick glance I can find any “Rock” below any “House.” I can quickly designate "folders" to show at the top of my Hierarchy window with the use of naming conventions. To avoid game object nesting complexity I can add a prefix to any game object's name to guarantee project organization. There is no way I will remember a custom sort order in every scene in every project when I need to find objects in future iterations of working on any given project. I have all kinds of questions about how this linear logic (layers like in Photoshop, which I am quite familiar with) will be handled in a 3d environment (which Photoshop layers do not handle,) but since I haven’t been able to work with uGUI yet I am reluctant to post such questions. I am excited about the new uGUI and look forward to making use of the features advertised, but I really wish you guys could come up with another means of handling depth sorting.

    Add my one vote to creating a separate window to handle this logic.
     
  24. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    So GetComponentsinChildren does not return in the order I specified, and it is still random in the internal storage. Then what's the purpose I would want to sort my objects for?

    Daikon Forge can do the UI Z order without upsetting the sorting order.
     
  25. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    GetComponentsInChildren will return the order you suggested assuming that your hierarchy is in transform order sorting (the new default). I was thinking you wanted to get the data out of the hierarchy window itself based upon the current sorting implementation.
     
  26. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    in 4.5.2 (i think thats the next public version going out) your are now able to turn on the alphabetical sorting without having to add a script to the project. You can then set your hierarchy to be in the alphabetical sort and then its like nothing has changed. Once Unity's GUI comes out then you are able to open a new hierarchy window in the new default sorting method and use that as the separate logic.
     
  27. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    The transform order does not appear to affect the order in which scripts execute - e.g. the order in which Update functions are called. Should it? I feel like it should...
     
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It doesn't seem like it should to me; you can use the script execution order settings for that.

    --Eric
     
  29. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    The execution order is "random" it shouldn't be something that is relied upon.
     
  30. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    True, but until 4.5, the same was true of transform order. Until I tested it just now, I had pretty much assumed that the two were based on the same order, I guess.
     
  31. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Well after speaking with people who know a little more about that system it's seems to be more based upon creation order which isn't the same as transform order. So yea they have always had the possibility of being different might just be more visible now
     
  32. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    I have noticed something strange in 4.5.1f3:

    1. Create an object with 3 or more children.

    2. Select each child (one at a time) and then open the GameObject menu tab....

    You will notice that "Set as first sibling" is the only available command for the first sibling and "Set as last sibling" is the only available command for the last sibling!?! Executing these commands does nothing, of course. Only the in-between children can be set to first or last without issue.

    This bug seems to be somehow connected to the random resorting bug reported earlier:
    If the first/last sibling index ordering is mixed-up then this might explain why the first child is becoming the last.
     
    Last edited: Jul 5, 2014
  33. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    @phil-Unity I've got yet another bug happening when children of a transform are prefabs. I've just checked the latest 4.5.1p4 patch and it's not fixed in there. I'm going to try and get a test case project to submit but this could be tricky.

    EDIT:

    For the record, the bug is #618359.
     
    Last edited: Jul 9, 2014
  34. Detocroix

    Detocroix

    Joined:
    Jul 2, 2010
    Posts:
    75
    I can understand why this system is setup for the uGUI, but also it sounds like people designing it haven't really used the softwares they used as examples (no offense!).

    None of the 3D programs really have any kind of effect on the hierarchy order EXCEPT on modifiers (this Unity already has, put components in order you want). These 3D programs also have a lot of tools to quickly manage and combine objects because handling even couple of tens in amount is hard. Group, combine, ungroup, unique names / autonaming copies (mesh1 becomes mesh2 on duplicating), detach, attach... Also in 3D programs you are VERY rarely handling hundreds of items at one time and when you are, you usually just combine scenes for rendering.

    The 2D programs (Photoshop) does have hierarchy based rendering but it has NOTHING to do with Unity. The workflow of Photoshop is a lot of effects, combining layers, making quick small adjustments on new layers and then flattening those. Photoshop becomes almost unusable at 50 layers and naming literally has no effect in Photoshop at all, it's just for you to know what layer is what and majority of people just name groups and leave layer names to whatever it comes up because it's not necessary unlike in Unity where naming is quick important.

    You compared the new sorting to 2D / 3D graphics creation softwares where you should have compared it to Windows Explorer... that's what it is. A list of gameobjects instead of folders and files arranged so that it is impossible to find them without search tool.
     
    benhumphreys likes this.
  35. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    I think you've got it backwards. You seem to consider automatic sorting as having no effect on the hierarchy. Actually, manual sorting is the only mode one could consider as having no real "effect".

    The whole reason for making the sorting comparable to a paint program was to allow users to sort GUI elements in the same manner that they would sort layers in Photoshop.

    I do, however, believe that when you give the users the ability to manually sort, you should also provide them some tools to help them keep things orderly. Similar to the functions you can find in Windows Explorer for sorting files. I created a tool to help with this, but more needs to be done in Unity itself.
     
    Last edited: Jul 8, 2014
  36. unormal

    unormal

    Joined:
    Jan 10, 2012
    Posts:
    65
    FYI, this new feature caused a pretty enormous performance hit in the editor with my very messy hierarchy. I had to package everything in collapsed parent folders to make it work smoothly. Perhaps I should have done this before, but I didn't, and so this upgrade sucked! :)
     
  37. hausmaus

    hausmaus

    Joined:
    Dec 9, 2011
    Posts:
    105
    For Phil, or UT in general,

    Would it be possible in the manual sort mode to have Ctrl-D duplicates appear directly below the selected gameobject? In even moderately complex scenes it is a noticeable workflow disruption and speed loss to have to resort duplicates so frequently.

    Thank you,
    Adrian
     
    StarManta likes this.
  38. RV1

    RV1

    Joined:
    Nov 18, 2012
    Posts:
    68
    I have updated to Unity 4.5.2f1. Unfortunately I have to report that I am still experiencing two issues which appear to remain unresolved:

    1. My changes to ordering within the hierarchy are lost when I hit play in editor. I have a lot of objects that for some reason stubbornly refuse to have their order changed. The objects in question are not prefabs. This makes me rather nervous for the upcoming 4.6 update, so I would very much like to know whats causing this and see it resolved.

    2. When objects are instantiated at run-time, they are added to the hierarchy in an inconsistent manner:
    - If a game object is created with new GameObject, then it gets inserted last.
    - If a game object is created with UnityEngine.Object.Instantiate(some_prefab) then it gets inserted first.

    Regards,
    RV
     
  39. chai

    chai

    Joined:
    Jun 3, 2009
    Posts:
    84
    Has alphabetical sorting been fixed yet ? it's really annoying
     
    Last edited: Jul 12, 2014
  40. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    The release notes say yes. Maybe look in the Preferences?
     
  41. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    You can enable it in 4.5.2 by opening up the preferences and checking the box next to "Enable Alpha Numeric Sorting". This will display an icon at the top of the hierarchy window that you can use to change the sorting mode.

    The release notes for 4.5.2 say:
    • Editor : Fixed issue with prefabs not maintaining new position if moved in hierarchy.
    • Editor : Fixed performance issues with large & flat scene hierarchies (new hierarchy window in 4.5 was slower on them).
    However, I checked in 4.5.2f1 to see if the set first/last sibling bug had been fixed, but it's still there. So I think they're missing something. I wonder if I should try to send a bug report about that? My gut feeling is that this tiny bug is completely related to the issues you're having.

    Something with the internal indexing seems to be amiss...
     
    Last edited: Jul 13, 2014
  42. chai

    chai

    Joined:
    Jun 3, 2009
    Posts:
    84
  43. Christopher Simon

    Christopher Simon

    Joined:
    Jun 28, 2014
    Posts:
    4
    I can confirm that the prefabs are no longer displayed in a random order in the hierarchy in 4.5.2 as they were in 4.5.1. Thanks for this fix and the new custom sorting method!
     
  44. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    301
    On the topic, does anyone have any idea how to change the order of transforms in the hierarchy through code?
     
  45. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Transform.SetSiblingIndex(), Transform.SetAsFirstSibling(), and Transform.SetAsLastSibling().
     
    rakkarage likes this.
  46. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    301
    Wow, easy haha. Great, thanks!
     
  47. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437

    Thank you for posting this script! I upgraded to 4.5 and was unpleasantly surprised to see my gameobjects were no longer in alphabetical order in the Hierarchy o_O

    I do scripting, but you making this script available was super easy for me to just download and put into my project. And most importantly, it worked! Thank you!

    Ya, my vote for the Unity dev team feedback would be to re-implement a button option that allows us to order our gameobjects by name if we want to. I understand the confusion with Beta testers and the new GUI, but this was fairly annoying.

    **One caveat: My game would NOT build correctly with this script due to a "No Unity Editor Namespace" error. So I did have to put the script in the Editor folder, otherwise it would not compile when building the game. But placing it in the Editor folder solved the problem.
     
    Last edited: Jul 31, 2014
  48. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    Yeah, that was noted a couple of comments after mine.
     
  49. budwheizzah

    budwheizzah

    Joined:
    Apr 3, 2014
    Posts:
    13
    This "feature" is garbage. Implemented like ass. Please resolve, it is shoddy and a waste of time.
    If plane manufacturers did this with their onboard software, people would die.

    I'm not even "script adverse", just you take something that should be a normal GUI control or at least have some indication of it and instead randsomly change its behavior and attach it to scripting. Zero visual indication, nothing to let us know you guys just decided because why not.
    The use is obvious. The horrendous covert implementation is inexplicable.

    The mystified faces you've caused are countless. "Wtf happened to Unity?" we ask, when we see random changes like this.
     
    Last edited: Aug 8, 2014
  50. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Could you be a little more constructive with your criticisms? Statements like "This "feature" is garbage. Implemented like ass. Please resolve, it is shoddy and a waste of time.
    If plane manufacturers did this with their onboard software, people would die." does nothing to tell us where you still feel the feature is lacking.

    I think you're referring to something that has already been addressed. You no longer need to write a script to have a-z sorting back. Its in the GUI in preferences (Edit->preferences). Scripting is now only required if you want to have some custom sorting.

    If i'm mistaken and thats not what you were referring to please give more details.