static void PrintComponents(GameObject gameObject, System.IO.TextWriter textWriter, int indentation = 1) { _MonoBehaviours.Clear(); gameObject.GetComponents <MonoBehaviour>(_MonoBehaviours); textWriter.WriteIndented(gameObject.name, indentation); textWriter.Write(":\n"); indentation++; foreach (MonoBehaviour monoBehaviour in _MonoBehaviours) { PrintComponentFactory.PrintComponent(monoBehaviour, textWriter, indentation); } Transform transform = gameObject.transform; int children = transform.childCount; for (int i = 0; i < children; i++) { PrintComponents(transform.GetChild(i).gameObject, textWriter, indentation); } }