How to get all my objects with hierarchy using c#?

How to get all object name with same hierarchy using C#

You can go through the entire hierarchy of an item by using recursiveness.
Here’s an example:

void Traverse(GameObject obj)
{
    Debug.Log(obj.name);
    foreach (Transform child in obj.transform)
    {
        // Call recursive on the child object
        Traverse(child.gameObject);
    }
}

Hai, Thank u for reply, Here I have full code,

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LocalisationManager : MonoBehaviour {

// Use this for initialization
void Start () {
    GameObject root = GameObject.Find("root");
    Traverse(root);
}
void Traverse(GameObject obj)
{
    //Transform[] allChildren = GetComponentsInChildren<Transform>();
  //  Debug.Log(obj.name);
         print(obj.ToString());
    foreach (Transform child in obj.transform)
    {
        // Call recursive on the child object
        Traverse(child.gameObject);
    }
}

}