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

Nested Prefabs

Discussion in 'Editor & General Support' started by topofsteel, May 28, 2015.

  1. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    I have Prefabs made from several other prefabs. I want to break the parent prefab without breaking all of the other prefabs. Is there a way to do that? Thanks.
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Unity does not support nested Prefabs. If you put a prefab inside another prefab you will loos the connection on the parented prefabs.
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    You could do this yourself by creating a script that has a collection of prefabs that it spawns on Awake. Then you drag-and-drop all of the prefabs you want to nest into that.

    This will allow you to manage those prefabs independently of the main prefab, but you won't be able to see them as a preview without doing significan amounts of editor magic.
     
  4. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    @fffMalzbier So it seems.
    The situation I have is I'm setting up smaller scenes for testing assets and lightmapping. But these are Identical portions of the larger scene. So after i've laid out my furniture or whatever, I drop them into an empty gameobject and create a prefab out of them. Then in my main scene I was just dropping in that prefab. For some reason I needed to break the prefab, the reason actually escapes me now. But I was left with no prefabs at all.

    I am lightmapping a big scene now and can't test it, but in some cases the prefabs are just an FBX from maya. Does breaking the prefab disassociate it from the fbx/mesh? If not, I could just update my meshes if there was a change. I'll test that, but i've never had a reason to break them.

    @Baste is there a way to 'copy' elements between scenes. I guess I would iterate through and get the name, location and rotation and re-populate the main scene. Do you know of any assets that already do that?
     
  5. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    There is also this as a solution: https://www.assetstore.unity3d.com/en/#!/content/2962

    Which I think Unity should purchase and implement this into Unity proper.
     
  6. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    No it does not. Even if the preafb instance is broken, the object still references the mesh from the FBX, so if you overwrite the old FBX, that should work just fine.

    In general, if you want to experiment on only parts of the scene, I wouldn't create a scene with only that part. Instead, I would put independent parts under different gameobjects, and then deactivate the ones you're not working on. That'll save you some time, and probably be easier to work with.
     
  7. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    Yea it would. I used to have a similar workflow in 4.x. But without Bake Selected I cant afford to re-bake the entire scene or not have a fully baked scene if the client wants a progress model.