Home Unity

Can you stop unity 5 auto incrementing prefab names in scenes?

polycounter lvl 19
Offline / Send Message
Frankie polycounter lvl 19
As the title says really, I'm finding it really confusing as my prefabs already have numbers in the names so I cant tell what's suppose to be what in the project view. Is it Tree_03 or the second instance of Tree_02??

Replies

  • ScribbleHead
    Options
    Offline / Send Message
    ScribbleHead polycounter lvl 13
    Would like a solution to this too, its extremely annoying
  • Richard Kain
    Options
    Offline / Send Message
    Richard Kain polycounter lvl 18
    Cook up a quickie script that looks for, and then removes any additional text appended to the end of a game object's name. Keep in mind, that this would provide all instances of that prefab with the same name, making them considerably more difficult to tell apart without manually selecting each one. There is a reason why Unity does that with prefab instances.
  • Hyshinara
    Options
    Offline / Send Message
    To get around the naming problem, simply name the prefabs Tree_A, Tree_B, etc instead of Tree_01, Tree_02, etc. Duplicates will still get numbers, but at least it won't be confusing.

    Though as Richard Kain said, having unique Game Object names can be very handy, so I'd also suggest renaming the first instance of Tree_A to Tree_A_01, so that any duplicates will immediately become Tree_A_02, etc, instead of having some with and one without a number...
  • Frankie
    Options
    Offline / Send Message
    Frankie polycounter lvl 19
    I don't know how to script and although I'd love to now isn't the best time to learn so was hoping someone had already done it. Apparently the next version of unity is going to change so the auto increments are inside brackets, hopefully that's true as it at least sounds workable to me.

    Richard Kain I don't understand why auto incrementing makes it easier to to tell whats what in a scene as it's still a list of arbitrary names, if I load my environment scene and it has 10 lamp posts in there's no way I can use the hierarchy view to accurately select the particular object I want. Its either trial end error or select the model in the scene view.

    Hyshinara I think it's too much effort to change my asset names near the end of my project.
  • NegevPro
    Options
    Offline / Send Message
    NegevPro polycounter lvl 4
    I just quickly wrote a script to do what I believe you wanted. Although I agree with what others said, I think the auto-renaming feature can be quite useful at times.

    Here's a download link to a unity package that contains the script and a prefab.

    http://www.mediafire.com/download/w6fmyl10ur58lce/Gameobject+Renamer.unitypackage

    To use it, simply drag the prefab into the scene and click it. Under the "Gameobject Name" entry in the inspector, type in the name of the gameobject you want to rename. Enter the new name in the string entry below that, then click on the little gear icon in the top right of the component name and select "Rename Gameobjects."

    It should then rename every gameobject that contains whatever you entered, so if you have Cube, Cube 1, Cube 2, Cube 3, etc., you could enter "Cube" then change the name to "myCube" and it will rename all of them.
  • Frankie
    Options
    Offline / Send Message
    Frankie polycounter lvl 19
    Thanks for having a go NegevPro, however there's something wrong with the prefab and it wouldn't do anything. Although from how you described it working, I'm not sure if it really helps anything as I can already select a prefab or model from the project view and rmb "find refrences in scene" then multi select them all and type the correct name into the inspector.
  • AlecMoody
    Options
    Offline / Send Message
    AlecMoody ngon master
    I also noticed this and I don't think unity 4 did this. It's super irritating when placing lots of copies of something in a scene.
  • NegevPro
    Options
    Offline / Send Message
    NegevPro polycounter lvl 4
    It appears I misunderstood what your request was then, plus I completely forgot about the Hierarchy Search function.

    If my understanding is correct now, you want to disable the auto-renaming function because you have prefabs "prefab_01" and "prefab_02" which are two different prefabs, but Unity considers them to be the same and so when you instantiate another of either prefab, it will be renamed "prefab_03." If this is the case, then Hyshinara gave a solid piece of advice with the naming convention, it would be easier if you named them "prefab_A" and "prefab_B."

    I updated the first script I wrote in order to follow Hyshinara's naming convention. Assuming this is actually what you wanted, then I believe this might have the functionality you wanted. http://www.mediafire.com/download/qjl77bd6piobodd/IncrementGameobjectNames.unitypackage

    To use it:
    1.) Drag the prefab into the scene
    2.) In the project view, right click the prefab you want to rename, such as Tree_1, and select "Find References in Scene"
    3.) Select everything in the hierarchy view
    4.) Type in the new name with the proper naming convention, such as Tree_A
    5.) Click the 'X' to remove the search filter in the Hierarchy view
    6.) Click the IncrementGameobjectNames prefab in the Hierarchy view
    7.) Type the name you used to rename the previous prefabs in the "Gameobject Name" entry, in this case it would be Tree_A
    8.) Click the Gear icon next to the component and select "Rename Gameobjects"

    This will rename every gameobject with a proper number, so in this case you would get Tree_A_0, Tree_A_1, Tree_A_2, etc. and it would only take a few seconds to rename everything, that way you could differentiate between Tree_A and Tree_B.

    Also, in case it doesn't do anything again, make sure you are clicking the right gear in the inspector, I tested my first prefab again by putting it into a new project and it seems to be working fine, so let me know if you have any issues or want any changes.

    If I'm wrong again, which I probably am, then just say the word and I'll jump headfirst into an incinerator.
  • Frankie
    Options
    Offline / Send Message
    Frankie polycounter lvl 19
    Haha stay away from the incinerator but that's not what I wanted either, actually I don't want to do anything. I'm far to late in my project and I've still got so much to do I don't want to spend time renaming all my models to fit a new naming convention (quick search says I have 962 of them!). The game also has a streaming system that relies on prefab or gameobject names to generate 64x64m environment tiles so I can't have auto incremented names in my environment tile source files.

    If you still felt like doing some scripting then maybe a version of duplicate, just like ctrl-d, but didn't increment the prefab name.
  • Richard Kain
    Options
    Offline / Send Message
    Richard Kain polycounter lvl 18
    Frankie wrote: »
    Richard Kain I don't understand why auto incrementing makes it easier to to tell whats what in a scene as it's still a list of arbitrary names, if I load my environment scene and it has 10 lamp posts in there's no way I can use the hierarchy view to accurately select the particular object I want. Its either trial end error or select the model in the scene view.

    If you select the model's name in the hierarchy view, the model will show up as selected in the scene view. If you double-click the object's name in the hierarchy view, it will shift the camera in the scene view to center on that particular object. That let's you know exactly which object you just selected.

    At that point you can change the name of the object in the hierarchy to be more specific, as desired. It's a little trial-and-error, that's true. But it's still better than having every object in a set named the exact same thing. Also, the auto-increment method at least gives you an idea as to the order in which the objects were added to the scene, as that's usually how their numbering works.
  • NegevPro
    Options
    Offline / Send Message
    NegevPro polycounter lvl 4
    Third time's the charm?
    http://www.mediafire.com/download/pau8rxb1bpc5yfu/RenameDuplicates.unitypackage

    I did a simple emulation of the duplicate command except it will maintain the names of the selected gameobjects or prefabs that you duplicate.

    How to use:
    1.) Import the package into unity (it's just a script now)
    2.) Select objects in scene or hierarchy you want to duplicate and press Ctrl + Alt + D to duplicate them.
    3.) You can press Ctrl + Alt + Z to undo the creation

    Hopefully this is the functionality you want or need, if not, feel free to ask for any changes because I'll do anything to procrastinate school work!

    EDIT: Also I just wanted to point out, for future projects you should definitely remember to try and maintain an organized naming convention, good organization can save a lot of development time!
  • Frankie
    Options
    Offline / Send Message
    Frankie polycounter lvl 19
    NegevPro, awesome! Could you make it remember the hierarchy it came from? I always have my objects inside a series of game object ready to be built into a tile prefab.

    Richard Kain, I understand that but having the auto incremented names makes no difference. The easiest way by far is clicking on the actual object I want in the scene, for my work there is no benefit having situational names. I get that I could start a new project and name everything in a way that would avoid confusion with the new way unity 5 handles objects but I'm not at the start of a project. And does anyone really want to name assets with alphabetical increments?
  • Frankie
    Options
    Offline / Send Message
    Frankie polycounter lvl 19
    This is fixed in unity 5.1, they changed it so the number gets put in brackets and preserves the name of the prefab. Eg Tree_02 Tree_02(1) Tree_02(2)
  • Hyshinara
Sign In or Register to comment.