Search Unity

Prefabs vs. scene organization

Discussion in 'Editor & General Support' started by islanddreamer, Jul 20, 2006.

  1. islanddreamer

    islanddreamer

    Joined:
    Apr 29, 2006
    Posts:
    473
    Ok, so I've got a lot of instantiated objects and I would like to group them together in the hierarchy window. But if I create an Empty Object and parent all the other objects to it, they lose their connection to the prefab, correct? If they don't, what am I doing wrong? I want to make tweaks to one object and have those changes cascade among all the instances.
     
  2. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    You can have prefab instances all being children of an empty GO. I've done that and it wasn't a problem for me.
     
  3. islanddreamer

    islanddreamer

    Joined:
    Apr 29, 2006
    Posts:
    473
    Ok. I think I was expecting to tweak the object in the scene, not the one in the project window.

    Now how about this: I've got a round building, with multiple stories. I want to place four columns on each level. Each column has a particle emitter at the top.

    I create an Empty object located at 0,0,0. I parent the particles to the column and the column to the empty object (why not just call it an axis?) and position the column and particles along the north wall. Now I create a prefab.

    I import the prefab 3 more times, rotating each by 90 degrees to end up with four columns circling the room.

    Now's the interesting part: I'd like to create a new prefab containing this column array so I can use it for the other floors.

    If I subsequently want to edit the particle emitter for all the columns on all the floors, can I go back to my original prefab or do I have to edit the four particle emitters contained in my array prefab?
     
  4. CoherentInk

    CoherentInk

    Joined:
    Jul 16, 2006
    Posts:
    216
    If I understand the problem that IslandDreamer has been having, I've been frustrated with the same thing.

    Essentially: is there a way to make a prefab that contains other prefabs?

    Making prefabs that contains prefabs would allow for complex structures and the ability to change the characteristics of children everywhere in the project, and not having to change multiple prefabs.
     
  5. islanddreamer

    islanddreamer

    Joined:
    Apr 29, 2006
    Posts:
    473
    Precisely. I'd like to be able to create Array Prefabs.

    But what about my original question regarding hierarchy organization? Is it safe to toss several disparate prefabs into an Empty Object in order to keep the window tidy? It would be great to be able to create folders or nested views within the hierachy without having to create a series of empty objects.
     
  6. CoherentInk

    CoherentInk

    Joined:
    Jul 16, 2006
    Posts:
    216
    It most certainly is safe to throw multiple prefabs into an empty GameObject. What are the downsides to doing that?
     
  7. islanddreamer

    islanddreamer

    Joined:
    Apr 29, 2006
    Posts:
    473
    That's what I wanted to know. You don't lose the ability to replicate changes if your prefabs are nested within other objects.
     
  8. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    You can safely have them as a child.

    So you could, create one column by placing several prefabs in a parent object. Then you duplicate that parent object and move it.


    Regarding how to tune in prefabs. Usually the way i use them is:
    drag the prefab into the scene, tweak it in any way (add components, children, modify properties etc.) It will tell you that it loses the prefab connection when adding a component but thats ok.
    When you are done tweaking you just select GameObject -> Upload changes to prefab. And all your other instantiated prefabs will look the same and the instance will be connected to the prefab again.