- Home /
Prefab brush and EnsureUniqueNameForSibling
Howdy,
I'm using the prefab brush from the 2D extras to paint prefabs.
The problem I'm running into is that each prefab instance created by the brush gives the objects the same name. I need these names to be unique. Even if it's just Object (1), Object (2), etc.
It seems like EnsureUniqueNameForSibling might do what I need, but for the life of me I can't figure out how to use it properly.
Anyone have any idea how to properly use that method? I know it would go in an Editor script, but that's about all I know.
Any help would be super appreciated.
Thank you!
When you instantiate the object, create a reference to it GameObject obj = Instanciate( ... ) as GameObject;
then insCount++;
followed by obj.name = "Panted ("+insCount+")
Hey! That will work great for objects instantiated at runtime. I'll definitely use that for those.
But what I'm also looking for is a solution to objects created in the edite - specifically objects created by a prefab tile brush.
ah so this is an editor script. (was thinking it was an ingame script). I'll need code to see where and how it's creating these objects. There are multipul ways of doing it.
Your answer
![](https://koobas.hobune.stream/wayback/20220612230940im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Mark gameobject field as changed from prefab 2 Answers
Editor-only circular contour around prefab instances 2 Answers
Editing prefab fields from custom editor that are not automatically serialized 0 Answers
EditorGUI add SortingLayer-like list to custom Editor 1 Answer
Unity Editor script in DLL 1 Answer