Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help! Duplicated Many Things without making Prefab!

Discussion in 'Getting Started' started by hikariakio, Aug 21, 2017.

  1. hikariakio

    hikariakio

    Joined:
    Dec 19, 2016
    Posts:
    25
    Hey guys..i forgot making prefab before duplicating an object to 200 X gameobjects with different positions..

    How can make a single prefab from All duplicated things?
    (Dragging into Project while multiple select doest work)

    I know i can make edit things equally while multiselected in hierarchy ..but is there a way?
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    No, there is no simple way to fix this. Well, not without writing some fairly fancy IDE scripts (or perhaps finding some off-the-shelf script for this, though I don't know of any off the top of my head).

    I think you need to delete 199 of those gameobjects, create a prefab, and then rebuild your scene using the prefab.

    Also, consider whether you really want all those prefab instances in your scene at edit time, or whether it'd be easier to instantiate them at runtime, with a bit of code in Awake or Start. Just a thought.
     
    Bill_Martini and Kiwasi like this.
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You could certainly write an editor script to do this. Basic strategy:
    1. Put all of the objects into a list
    2. Store the positions and rotation in a second list
    3. Delete all of the objects
    4. Create new objects from a prefab
    5. Assign each new object a position and rotation from the list previously stored
    If you are familiar with editor scripting, you could probably whip that up in a shorter time then it will take to reposition the objects manually.
     
    eXonius and Bill_Martini like this.
  4. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    Or bite the bullet and make a prefab from one of your objects, delete, and start over. We all have done stuff like this. Sometimes it's painful, and sometime it's real painful. Try to learn from this as it's the only positive thing that can come from screw-ups. We all seem to do these things once in a while, an unavoidable down side of being human.
     
    Kiwasi likes this.