- Home /
child names of clone dont match model
if you can see in the attached image, i added 2 gameobj references to the script 'Level_GUI' on 'MainCamera'. the gameobj's are named 'QuadShot'
Notice how the model (in the project view, with the yellow ring highlight) has children named 'CannonBall1,2,3,4' but the clone (visible in the hierarchy view) that is created in Level_GUI::Start() has 4 children named 'CannonBall'
stuff like this is usually my fault - so im not calling it a bug yet, but i cant reason it out
Answer by Bunny83 · Aug 27, 2012 at 10:44 AM
When you clone / instantiate an object, Unity appends "(Clone)" at the end of the name. You can set the clones name when you instantiate the object:
Since i can't determine your language, i start with C#:
// C#
public GameObject prefab;
// When you instantiate the prefab:
GameObject clone = (GameObject)Instantiate(prefab);
clone.name = prefab.name; // replace the name with the prefab name.
The same thing in UnityScript:
// UnityScript
var prefab : GameObject;
// When you instantiate the prefab:
var clone : GameObject = Instantiate(prefab);
clone.name = prefab.name; // replace the name with the prefab name.
Note: I used a GameObject reference for the prefab, but it works with Transform, Rigidbody or with any other attached component as well. So you might have to adjust this to your used type.
Ok, i just reread your question and i think you talk about something else :DI never have seen this behaviour before, maybe it's something new in 3.5+
Your answer
Follow this Question
Related Questions
Instatiated objects should have all the same name. 2 Answers
Access the renderer of a clones child object 1 Answer
Finding a child without knowing its name? 1 Answer
Is a clone object still a (clone) if you change the name of it using script? 1 Answer
instantiated Gameobject trying to access child of child which is a clone itself. 2 Answers