Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
4
Question by Evallis · May 29, 2014 at 06:14 PM · hierarchywindowsortingnot-working

hierarchy is not in order

I just downloaded the new update (4.5.0f6) and now my hierarchy window is messed up. It seems to be that everything that is not a prefab (white letters) is sorted correctly but everything that is a prefab (blue letters) is not sorted at all. I have tried reloading the scene, loading a different scene, restarting Unity, and restarting my computer but nothing has helped. Before the update everything was working fine, but now it is just an unorganized mess.

Is this a bug with the update? or did I do something that caused this?

Thanks.

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 supernat · May 29, 2014 at 06:31 PM 1
Share

It's a long awaited feature to allow reordering based on transform. Note that order within the editor in the older versions was not guaranteed to be the same (nor was it usually) when you run the stand alone version. I'm hoping with this latest feature, the order will be consistent across devices as well, haven't tried that though, but most of my code doesn't rely on ordering due to the legacy operation. That would make some UI utilities easier to use because you won't have to state an explicit order necessarily and can rely on the Transform child order. It will take some getting used to though, because I've adapted (probably like yourself) to seeing everything in alphabetical order.

avatar image MrDude · Dec 19, 2014 at 09:01 AM -1
Share

All I want to do is find out how to order gameobjects at runtime but it seems that can't be done???

So how do you make one object go behind another and back again based on button presses? Have they made this impossible now???

4 Replies

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

Answer by karljj1 · May 29, 2014 at 06:27 PM

This is a new feature. You can now re order the structure of objects manually or write a script to make it alphabetical again if you wish.

http://unity3d.com/unity/whats-new/unity-4.5

New Hierarchy Window sorting - sorting of elements is now based on transform order instead of name.

Comment
Add comment · Show 3 · 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 Evallis · Jun 02, 2014 at 08:42 PM 3
Share

Ah I see, thanks!

For those who have this same issue, here is a script.

 using UnityEngine;
 using UnityEditor;
 
 public class AlphaNumericSort : BaseHierarchySort
 {
     public override int Compare(GameObject lhs, GameObject rhs)
     {
         if (lhs == rhs) return 0;
         if (lhs == null) return -1;
         if (rhs == null) return 1;
         return EditorUtility.NaturalCompare(lhs.name, rhs.name);
     }
 }

when this compiles there will be a little icon next to the search bar on the hierarchy window, click that and you can switch between transform or alphabetical sort.

avatar image karljj1 · Jun 06, 2014 at 04:16 PM 1
Share

Its worth noting one of the reasons for this is so you can adjust the order that layers are drawn in the new GUI system by simply re-ordering their hierarchy.

avatar image 3dMOose · Oct 23, 2014 at 04:44 PM 0
Share

Now, if I figure out how to force Shuriken particle sorting based on this, my life would be much better.

avatar image
9

Answer by Calos1591 · Jul 24, 2016 at 06:20 AM

alt text

Enable Alpha Numeric Sorting


alpha.jpg (37.6 kB)
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 yazi · Mar 22, 2017 at 06:18 AM 0
Share

A+ and it worked...

avatar image Daynil · Nov 19, 2017 at 07:49 PM 0
Share

This is great, it actually adds an options box rather than just enabling it, so you can switch between the two as needed (on v2017.2). ][1]

sorting.jpg (10.6 kB)
avatar image
3

Answer by IsaiahKelly · Jun 08, 2014 at 12:02 AM

Using that script to bring back the old hierarchy view will actually cause more problems down the road since it wont work with the new uGUI system coming to Unity 4.6. So it's not recommended.

However, I did create a tool over here to allow users to easily reorganize their hierarchy since the 4.5 update that doesn't require the old system at all.

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 8bitgoose · May 26, 2015 at 09:56 PM

This script will allow you to sort one level of child objects in the hierarchy. Helpful when you need to sort objects that hold lots of similarly named prefabs.

NOTE: it is a crappy bubble sort that isn't efficient. But it did organize about a hundred items in 87 milliseconds. You won't notice it when you need it.

 using UnityEngine;
 using UnityEditor;
 using UnityEngine.UI;
 
 public class SortChildObjects : EditorWindow {
 
     [MenuItem("GameObject/Sort By Name",false,-1)]
     public static void SortGameObjectsByName(MenuCommand menuCommand)
     {
         if(menuCommand.context == null || menuCommand.context.GetType() != typeof(GameObject))
         {
             EditorUtility.DisplayDialog("Error", "You must select an item to sort in the frame", "Okay");
             return;
         }
 
         GameObject parentObject = (GameObject)menuCommand.context;
 
         if(parentObject.GetComponentInChildren<Image>())
         {
             EditorUtility.DisplayDialog("Error", "You are trying to sort a GUI element. This will screw up EVERYTHING, do not do", "Okay");
             return;
         }
 
         // Build a list of all the Transforms in this player's hierarchy
         Transform[] objectTransforms = new Transform[parentObject.transform.childCount];
         for(int i = 0; i < objectTransforms.Length; i++)
             objectTransforms[i] = parentObject.transform.GetChild(i);
 
         int sortTime = System.Environment.TickCount;
 
         bool sorted = false;
         // Perform a bubble sort on the objects
         while(sorted == false)
         {
             sorted = true;
             for(int i = 0; i < objectTransforms.Length - 1; i++)
             {
                 // Compare the two strings to see which is sooner
                 int comparison = objectTransforms[i].name.CompareTo(objectTransforms[i+1].name);
 
                 if( comparison > 0) // 1 means that the current value is larger than the last value
                 {
                     objectTransforms[i].transform.SetSiblingIndex(objectTransforms[i + 1].GetSiblingIndex());
                     sorted = false;
                 }
             }
 
             // resort the list to get the new layout
             for(int i = 0; i < objectTransforms.Length; i++)
                 objectTransforms[i] = parentObject.transform.GetChild(i);
         }
 
         Debug.Log("Sort took " + (System.Environment.TickCount - sortTime) + " milliseconds");
 
     }
 }

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

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

30 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 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 avatar image avatar image avatar image avatar image

Related Questions

Highlighting / Focusing on an Editor Window Through Code 1 Answer

The best way to sort list of gameobjects in order I need? 0 Answers

How does one access the Hierarchy Window? 2 Answers

Making a glass/window shader with cubemap reflection and transparency options 2 Answers

Some questions about Gui.Window 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