- Home /
"Name (Clone) (Clone) = Name" change?
so removing the two "(Clone)" on the name of the gameobject?
Answer by ben-rasooli · Aug 14, 2020 at 11:51 AM
"string value".Substring(0, value.IndexOf("(Clone)")).Trim();
In your case it will be: gameObject.name.Substring(0, value.IndexOf("(Clone)")).Trim();
Answer by Bunny83 · Aug 14, 2020 at 01:15 PM
This is usually a sign you're doing something "wrong". Not necessarily wrong but I'm not sure if you actually understand what you're doing. This is a common issue when people give a prefab a reference to itself. This reference is not preserved when the prefab is instantiated. Instead, like all other internal references, it gets replaced by a reference to the newly created instance. So when you use your "prefab reference" again, you actually do not instantiate your original prefab, but you just clone the object in the scene. So you create a clone of a clone. This might not matter, but be aware that the new clone copies the current state of the source object.
Apart from that when you want to get rid of the "(Clone)" suffix that is added each time you clone an object, you can set the name right after you instantiated your object. For example
GameObject clone = Instantiate(prefab);
clone.name = prefab.name;