Name of the prefab generated by Instantiate Create a program that is obtained by GameObject.Find () and the first prefab that was generated first points to the A object, the second prefab that is generated points to the B object ... doing.

I have to change the name of the generated prefab for each prefab, but I don't know how.

The way I think is
"If the object name in the hierarchy has a name of" 1 ", it will be named" 2 ". If it has a name of" 1 "," 2 ", it will be named" 3 "."
Is it possible to get the names of the objects in the hierarchy?

cube = (GameObject) Resources.Load ("Prefab);
GameObject hoge = Instantiate (cube, gameObject.transform.position, Quaternion.identity) as GameObject;
hoge.name = numbering;
↑ I write like this now.

  • Answer # 1

    GameObject [] gameObjects = FindObjectsOfType();to get all game objects and check their names.
    However, since all game objects are searched, the operation is slow.

    Therefore, I think that it is better to prepareListor something, and manage the generated game object.