Renaming whole game objects hierarchy

Hi community,

is there a possibility to rename the whole hierarchy of a gameobject (here: of a character bones hierachy) with:

  • getting each child
  • get its name
  • set a prefix like (“worker01_”)
  • set the new name of each child

in c#?

Many thanks for help!

Hi, found the solution:

public GameObject Original;
public GameObject clone;

void Start ()
{
    clone = (GameObject)Instantiate(Original);

    Transform[] allChildren = clone.GetComponentsInChildren<Transform>();
    foreach (Transform child in allChildren)
    {
        child.name = "ChildName";
    }
}