How do I stop Unity 5 from changing my object names when adding them to the scene?

As from Unity 5, Unity has started auto-incrementing your object names if they end with a number.

So if I have a prefab called “Sofa_1”, and I drag two of it in the scene, the second one will be automatically renamed to “Sofa_2”.

Duplicating an object in the scene will also either auto-increment its trailing number, or add a new trailing number to it.

This behavior is driving me bonkers because it’s causing me to lose track of which files I have in my scene.

How can I stop this behavior?

3 Likes

I don’t think this optional and agree it should be.

Meanwhile, you can have your prefabs names finish with “_” if they had a number, this way you can still look for “sofa_1” without having it rename “Sofa_2” which could be the name of an other prefab.

I suggest you report it has a bug, since this feature can ruin your workflow: I managed to have them remove an other unwelcome feature like that. Considering users can already have a big collection of prefabs with numbered names, they’ll understand the situation.

I’m still on beta 20 so obviously I still can see this problematic behavior but I think I remember seeing a release note about that not happening anymore. Is that still the case with the latest release ?

This is still happening in RC2. I agree it should be an optional thing, as sometimes it’s what I’d want, but other times you have numbered assets that don’t need to be unique.

There would still be the issue of duplicating an object in the scene to which Unity adds a trailing number to the copy.

And still, if you’re using third party packages with hundreds of prefabs, renaming all of them is simply not an option.

Hi!

The new behavior is meant to protect users from animation problems.

You have a gameobject “Hand”, you duplicate it and suddenly you can’t animate both. To be easily retargetable, the animation system binding works on top of unique gameobject names (or hierarchy paths). This is something we are not willing to change. So we tried to do something else to protect users: Incremental naming by default.

No change comes without pain and I can see how we have stepped on a landmine here: Project view encourages incremental naming for prefabs and now scene view encourages the same. This combination gets quite messy very fast. We didn’t see this coming. Sorry about it.

Now we could go for this being an option somewhere in the editor/project settings, but options like that should be last resort. If you always just solve all design problems with yet another option tucked away somewhere, you quickly end up in a very dark place.

So here is a suggestion of what we could do:

  • You have prefab called “rock”

  • You instantiate it and it becomes “rock”

  • You instantiate it again and it becomes “rock (1)”

  • You instantiate it again and it becomes “rock (2)”

  • You have prefab called “tree_2”

  • You instantiate it and it becomes “tree_2”

  • You instantiate it and it becomes “tree_2 (1)”

  • You instantiate it and it becomes “tree_2 (2)”

Thoughts?

6 Likes

Hey keely,
Thanks for explaining the reason behind the change!

I think the suggestion you presented would work better than the current one since at least it doesn’t alter your original prefab name.

That said though, I would personally value the option to completely disable this helper feature more because when it comes to direct cloning in the scene, I will still end up renaming the cloned prefab instances because otherwise I’d end up with an inconsistent naming scheme, i.e. the first one will be “Sofa_1”, then “Sofa_1 (1)” and “Sofa_1 (2)” (the first prefab doesn’t contain parentheses while the others do, hence the inconsistency).

Thanks for replying.

If the feature can be disabled, anything created with it disabled will work poorly with the Animation feature and potentially result in very confusing behavior that can look like bugs. So we’d really like to avoid that unless there’s a really good reason.

Can you tell us a bit about in what way the proposed naming scheme (some prefab instances have numbers in parenthesis and the first one not) would be causing you trouble? Is the inconsistency getting in the way of some of your workflows?

How about a more advanced option that would cost mere months of manpower? :wink:
Let us write filters for the handling of this :stuck_out_tongue:

Hey Rune,
Thanks for replying.

That is understandable, although I could potentially see a lot of people getting bit by having same object names in Animation objects if no Console Warning is shown.

That parentheses thing won’t really get into the way of my workflow per se; it just goes against the naming conventions our team are using for the current project, i.e. same prefab instances in the scene all use the same exact names (like it was in Unity 4), except the ones involving animations.

But still, it’s not a major problem for us and keely’s proposed system is definitely something we can work with. It’s way better than the current auto-name-increment system.

Great suggestion!