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

Showing deeper nested levels in Prefabs (project-view)

Discussion in 'Wish List' started by jashan, Jan 4, 2008.

  1. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    I'm not sure if this is a bug, or if I did something wrong, or if I just don't understand something. I have a prefab of a somewhat complex object, most of which are things I've assembled directly in Unity. In the project view, I see the prefab, and I can look at its contents - but I only get one hierarchial level, not the deeper levels.

    When I drag the prefab back into the scene, the sub-levels are shown correctly in the scene view. I've tried creating a new prefab from the same object, but I still get only one hierarchial level in the project view.

    This behavior can be reproduced quite easily: Just create 3 empty game objects, drag them under each other so each is a level below the previous one, create a prefab of this game object, and in the project-view, all you see is the first level (so you see the 2nd game object, but not the 3rd).

    It's not a big deal, so I wouldn't really file it as a "bug", more as a "feature request". The reason I stumbled upon this is because I wanted to remove some reference points I didn't need anymore directly from the prefab (in the project view). They were deep in the hierarchy, so I don't see them in the project view, so I can't delete them.

    It's no big deal - I can remove them from one of the instances and "Apply changes to prefab" and that's it. Still, it would be nice to be able to do that as extra step... so, I guess this is a feature-request, so I'm putting it under Wish List ;-)

    Jashan
     
    sami1592 and MartijnIvory like this.
  2. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    That is by design - from a scene, you can make references to game objects you can see in the project view; the ones nested down one level in a prefab.

    We've limited that to one level for a few reasons:
    - A larger level made by an artist can have many, many game objects inside it. Letting people make references to game objects deep in the hierarchy seemed to be dangerous, as it would be too easy to introduce code dependencies on arbitrary art assets.

    - In code-based prefabs, its usually more flexible to have some accessor properties in the root game object that has pointers to what you need.

    It seems to me that allowing deletion of gameobjects directly inside prefabs is actually a bad idea. Don't you want to see what you're doing? (If you are a programmer who has a complex manager setup, you can probably handle it - but prefabs are also used for graphics, and there you want to see what you do anyways)
     
  3. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Thanks for the explanation - that makes sense to me... Guess in that case, Unity was smarter than me ;-)
     
  4. MatthewW

    MatthewW

    Joined:
    Nov 30, 2006
    Posts:
    1,356
    We find ourselves frequently editing prefabs at deep levels. Usually it's to reference something internal on the prefab (ie, when we rig up destructible doors in our jeep game we need to point to all of the existing doors).

    I probably drag a prefab in, edit something in the hierarchy, and apply changes back to the prefab at least a few times a day. Personally I would love to see deeper prefab editing and a more robust prefab-inside-a-prefab paradigm.

    Actually, how about this:

    Double-clicking a prefab brings to you to a scene view with just that prefab instantiated in the scene hierarchy. So you can see the prefab in 3D, edit whatever you need to, and then when you close out of this view it goes back to whatever level you were previously editing...
     
    sami1592 likes this.
  5. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Agreed, that would be a very good solution.
     
  6. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Yeah - I've wanted to do this for quite a while...
     
  7. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Cool! I guess I'll be using that a lot, too ;-)
     
  8. Polygans

    Polygans

    Joined:
    Apr 19, 2009
    Posts:
    79
    I also voice my request for a deeper Hierarchy view in the editor. Simply because its not consistent to not be able to see it.

    I wasted a good amount of time trying to figure out why the prefab would not show my other things I had in the Hierarchy before turning it into a prefab.
     
  9. Rapzid

    Rapzid

    Joined:
    Apr 25, 2009
    Posts:
    123
    +1 I've been making my top level just a container for the rest of my package. It exposes a few key setup variables and allows you to move the whole rig but that's about it. For instance, I have Rocket at the top, then Rocket_obj and Rocket_target under it. And I have Rocket_trail under the Rocket_obj as a particle emitter. Unfortunately I can't see or tweak that object with the particle emitter from the prefab which is very frustrating. It took me a while to come to terms with that... I thought I was doing something wrong.
     
  10. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    To add my 2p's worth, what I'd like to see is a Publish/Subscribe version of nested prefabs.

    I want to make a prefab out of multiple sub-prefabs, be able to tweak one of the original sub-prefabs and have it propagate.

    EG:
    Make an engine prefab with particles and lights.

    Make a Red ship prefab that uses the engine prefab.

    Make a Blue ship prefab with different componenets, including the engine prefab.

    Be able to tweak the engine prefab and have it propagate to all iterations of the engine prefab, even tho' it's a sub-prefab in several other prefabs.
     
    AlasdairHendry likes this.
  11. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Why can't I see and edit more than 1 level deep in prefab? This seems very odd and I have to bring the prefab to the scene and edit and recreate prefab.
    It doesn't seem very logical whatever the reason is.
     
  12. ElmarKleijn

    ElmarKleijn

    Joined:
    May 11, 2009
    Posts:
    87
    Just want to add my vote for a deeper level visibility as well. Right now I need to place the object, zero all root vectors, modifiy the values in level 3-4, apply and delete the object.

    Not very convienent :).
     
  13. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    On the other hand, I think Nicholas has some very good points for not being able to edit the prefabs without seeing what you are doing. The compromise of double-clicking the prefab to bring it into a scene view "prefab editor" would be great.

    I still want to push the need for automatically updating nested prefabs, however!
     
  14. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    I don't need to be able to see it, like he said I am a programmer and can handle it. There should at least be an option. It's not productive to me at all to have to drag an instance into my scene and change it, then reconnect it, just to change a single value in a deep script.

    Hmm, I'm actually not that annoyed by it, but I guess it sounds like I am......
     
  15. lazalong

    lazalong

    Joined:
    Oct 13, 2009
    Posts:
    139
    +1

    Has someone made a feature request for it?
     
  16. sidestepper

    sidestepper

    Joined:
    Oct 2, 2008
    Posts:
    96
    +1 for the NESTED PREFABS - The double click to expand is cool too, but if I had to choose one or the other, nested prefab wins hands down, and here's yet another example why:

    I am making a large MMO, by large I mean MANY maps and various updates over time, not in player base, I'd be surprised if I get a lot of those, but still...

    So, I wanted to have my artists make multiple unity projects, each representing one of the many scenes in the game world, then convert those scenes they crafted to the asset bundles that the game client loads from map to map - but I found out you can't make scenes into asset bundles, I would have to make the entire scene a prefab, then export that prefab as an asset bundle. The problem with that is in all their scenes there are hundreds of instanced prefabs already in the root scene object, so if I make that root scene object a prefab, all that instancing is lost as the entire map is now a single instance of 8759034286023 unique objects. This makes it a very heavy weight, less than optimal solution. If support for nested prefabs existed, then that means even if I made that root object a prefab, Unity would know it's a prefab containing other prefabs which are instanced, which is the light weight, optimal solution.
     
  17. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    You can make scenes into asset bundles. I know there is a topic about this somewhere, but if you don't find it I will post an example tomorrow. I have to go home now though.
     
  18. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    scenes itself can't be made to asset bundles, but you can make the whole content of the scene one and then instantiate the whole bundle basically.
     
  19. sidestepper

    sidestepper

    Joined:
    Oct 2, 2008
    Posts:
    96
    Exactly, I'd have to make all the objects on the scene a single prefab - which there in lies the heart of the problem, if I do that, then all the instanced prefabs that were inside of that scene are no longer instanced, each one is counted as a unique object in the scene prefab. Unless Unity is somehow instancing them, but I wouldn't think so based on how Unity behaves with prefabs inside of prefabs(Seems once a root object containing prefab instances becomes a prefab itself, those children prefabs are no longer linked or instanced as the prefab they once were, rather they are each unique objects belonging to the new parent prefab)
     
  20. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    Well they are not Asset Bundles exactly, but you can use them in the same way without any changes to your code except building them.

    Use this to build them:
    Code (csharp):
    1. string[] scenes = { "assets/scenes/scene1.unity", "assets/scenes/scene2.unity" };
    2. BuildPipeline.BuildPlayer(scenes, "destination.unity3d", BuildTarget.WebPlayer, BuildOptions.BuildAdditionalStreamedScenes);
    Then to use them, simply download them like normal asset bundles using WWW. And when the download is complete, you can call Application.LoadLevel("scene1") (or any variant of it).
    * Edit: And you do have to set a value equal to myWWW.assetBundle so it can load it properly.

    If you're unsure about anything, download the StreamingWorldDemo Example from Unity and check out GenerateScenes.cs and ZoneLoader.cs. Oh, and change everything that says Asynchronous to Async or it won't compile.
     
  21. sidestepper

    sidestepper

    Joined:
    Oct 2, 2008
    Posts:
    96
    I'll check out the streaming world demo, but based on what I've read about Web Player Streamed stuff, I think I would have to add each scene to my build settings still, which means I would have to have each scene in my client project, which defeats the purpose of why I'm doing this - to have a modular world, where all I need to do on the client is ask my server, "ok I went here, what file do I need to load for this part of the world" and the server will hit the database and grab the asset bundle or whatever, and drop that back to the client so he can load it on the fly. This means the world can grow or shrink by me changing the database and the client will not have to change.

    But I could be misunderstanding - I will check out the streaming demo and post here if I find something that will work in that modular way. Thanks for the infos.
     
  22. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    I don't understand how you envision this could happen. What code dependencies? If we're talking about Find()/GetComponentInChildren(), doesn't that cover all depths of a prefab anyway? If we're talking about stuff that's been wired up in the Unity Editor, won't the Show Dependencies system pick it up correctly anyway?

    However, that means that you're also coupling your root game object type to the types of all the components in the object, which seems less flexible to me. I can see that it's sometimes going to be better design to ask the root of the prefab to give you child objects instead of going hunting for them yourself, but allowing people to dig deeper into prefabs wouldn't prevent anyone from doing this, and it would allow better solutions for the cases that aren't "usual."

    My use-case: I recently spent a couple of days working with our lead artist to tune a bunch of our special effects. We'd keep the game in 'play' mode, and tweak the settings on the prefabs directly, seeing the results when the effect got spawned again a few seconds later. There was no explicit 'apply' step needed because we were working with the prefabs directly; this made for a very smooth workflow. Some effects, however, are part of deeper hierarchies (for example, the FSFX on the main camera, which is 3 levels down from the player object), and we had to fall back to a stop-start workflow for these, because we couldn't touch the prefab in the right places. (Even pausing the game and hitting 'apply' was no good, because other parts of the player's state might have changed - we had to resort to writing down the values we'd changed and then re-entering them back in the editor).
     
  23. warby

    warby

    Joined:
    Mar 23, 2009
    Posts:
    162
    i would very much like all children to be displayed in the project view !
     
    MrDizzle26 likes this.
  24. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    /me casts resurrect

    I just had this issue and found it quite odd, in fact I was worried my prefab was broken and missing something, so it goes against good interface design practices.

    Even if we can't edit all levels of a prefab, why not just show all of the levels and have them slightly greyed out to indicate that level 2+ are locked. This way we can at least see what a prefab contains without being able to edit those extra levels.

    Having said that, I don't agree with not being able to edit the nested levels anyway, especially since you can edit level 1 and 2. It's not consistent, and technically you could mess things up since you can edit those first two levels at any rate.

    In summary:
    Worst case - let us see the whole tree, but not edit levels 2+

    Best case - let us edit the whole tree (or add it as an option in the Unity preferences that defaults to Off).
     
  25. Ming

    Ming

    Joined:
    Sep 21, 2011
    Posts:
    2
    I was also caught by this "feature". I understand the need to protect sensitive parts of the data. However, perhaps there is a better way to do this that also allows inspection and/or modification of deeper hierarchies?

    Protecting sensitive parts of the data is
    1) A general issue which should be addressed on an entire Unity editor-wide in a consistent way
    2) Not congruent with the spirit and design philosophy of a game editor that allows a much greater complexity and control over game objects than all other game editors!

    It should not be
    1) Enforced on a single arbitrary system that the user may or may not want
    2) Inconsistent by being only on *one* particular aspect of the editor. This just causes confusion and causes this thread to grow year after year.
    3) Confusing to the new user
    4) The default behavior which causes the user to go "WTF??!" and have to spend hours assuming he did something wrong and then having to do a search on Google to find this thread to determine that this particular "WTF??!" is "as designed"
     
    Last edited: Jan 3, 2012
    MrDizzle26 likes this.
  26. crowmagnon

    crowmagnon

    Joined:
    Mar 2, 2011
    Posts:
    36
    I was also just bit by this problem of not being able to see nested prefabs. This thread was started 4 years ago, and this still remains an issue. I have no problem putting in a feature request, but it seems that since this has been a known issue for quite some time and still has not been changed, perhaps it's already been decided that it's not going to change?

    Could an administrator or unity developer chime in here on whether this is something worth requesting anymore and what the developers currently think about this issue given the feedback in this thread? Or perhaps there are already plans on how to fix this confusion? Thanks.
     
  27. bricevdm

    bricevdm

    Joined:
    Nov 4, 2009
    Posts:
    34
    non-sense, where can i vote against this? i used to think the staff listen to the user base..
     
  28. Chris Pine

    Chris Pine

    Joined:
    Nov 30, 2012
    Posts:
    1
    For myself (and lots of others here), limiting the depth to one level isn't stopping us from nesting more deeply; it just makes it more difficult and error-prone to do.

    Please change this, or at least make this an option. I don't appreciate you setting limits on my development because you are worried that it might be dangerous for me. Let me make that decision, ok? Because maybe I know more about my particular situation than you do. :)

    From http://www.paulgraham.com/langdes.html:

    Please don't be my governess. :p
     
    Starya likes this.
  29. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    Same exact problem here.
    Lots of time waisted on loading the prefab to a scene, making changes to the deeper hierchy children and then recreating the prefab. Specially for prefabs used in NGUI. And once the prefab is recreated all links to object references in scenes that are using the changed prefab are lost.
    In addition lots of time waisted wondering where in the world the deeper children went, to start with.
    As a minum show the children in the hierchy and mark them as "not available for changes" somehow. Different color label perhaps. But again, I think allowing changes to the children is a must. I am one of those people who tends not to get things perfect the first time around. Often !!!!!
     
  30. Errorsatz

    Errorsatz

    Joined:
    Aug 8, 2012
    Posts:
    555
    Agreed on, at the very least, showing the deeper levels even if they're not modifiable. Often, you may want to search through your prefabs to see if any of them are using a particular component/object/whatever. The fact that things two levels down aren't shown means you have to drag out every single prefab that's more than a level deep, or risk missing a hidden child object.

    And IMO, there's no reason I shouldn't be able to modify prefabs if necessary. Make it an advanced setting that has to be enabled, sure, but I know what I'm doing and adding extra steps doesn't make it any safer.