Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Instantiation Naming - ' "originalName" + (clone) ' vs ' "originalName" + i ' - feature request

Discussion in '2020.1 Beta' started by noyogiisMYusername, Jul 17, 2020.

  1. noyogiisMYusername

    noyogiisMYusername

    Joined:
    May 18, 2020
    Posts:
    21
    This could be as an option flag or just a plain old change of method but I'm curious how many people really want a bunch of same named clones running, rolling, or sitting around. Its not a big deal to add a iteration to the end of their name, but I can't help feel a little stupid removing the clone part of their name before adding a number. If instantiating something, there's a good chance that the original isn't in the scene, so they are all clones, it seems a little redundant to tack clone on to their name, it would be great if instead of tacking clone on to the prefabs name it were a number. If there does happen to be an original in the scene then that one just doesn't have a number.
     
    Sidema likes this.
  2. SurprisedPikachu

    SurprisedPikachu

    Joined:
    Mar 12, 2020
    Posts:
    84
    Even though it might sound like a good idea on the outside, tracking the index for each prefab is going to be an unnecessary overhead in the instantiation process. So I don't think they ever add such a feature.

    As an alternative, you can always set the name of your object after instantiation:
    clone.name = prefab.name + " " + index;
     
  3. noyogiisMYusername

    noyogiisMYusername

    Joined:
    May 18, 2020
    Posts:
    21
    In my use case I am instantiating clones one at a time and then immediately adding them to a list, before adding them to a list I am removing the clone part of their name by renaming them. While a list does all the numbering I need, I think it would be nice to have a say in how the instantiatees are named.

    Instantiate - Could return instances with prefab.name
    InstantiateClone - Could return instances with prefab.name + "(Clone)"
    InstantiateIndexed - Could return instances that are indexed
     
    Last edited: Jul 19, 2020
  4. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    Why do you want Unity to do this, instead of doing this yourself?

    You can instantiate and then immediately set the name.