private void GetObjectListFromHierarchy(List<Object> hierarchy, GameObject gameObject)
{
Transform transform = null;
List<Component> results = new List<Component>();
gameObject.GetComponents<Component>(results);
foreach (Component component in results)
{
if (component is Transform)
{
transform = component as Transform;
}
else
{
hierarchy.Add(component);
}
}
if (transform != null)
{
int childCount = transform.childCount;
for (int i = 0; i < childCount; i++)
{
this.GetObjectListFromHierarchy(hierarchy, transform.GetChild(i).gameObject);
}
}
}