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.
Enable Alpha Numeric Sorting
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.
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.
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 *= 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*.name.CompareTo(objectTransforms[i+1].name);*_
* if( comparison > 0) // 1 means that the current value is larger than the last value*
* {*
_ objectTransforms*.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 = parentObject.transform.GetChild(i);
* }*_
* Debug.Log(“Sort took " + (System.Environment.TickCount - sortTime) + " milliseconds”);*
* }*
}