public static void AppendNameRecursively(GameObject gameObject, string name, bool root) { if (root) { gameObject.name = name; } else { gameObject.name = UXUtils.FormatAppendedName(gameObject.name, name); } Transform transform = gameObject.transform; int i = 0; int childCount = transform.childCount; while (i < childCount) { UXUtils.AppendNameRecursively(transform.GetChild(i).gameObject, name, false); i++; } }