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

[Official] Prefab Improvements

Discussion in 'General Discussion' started by bibbinator, Jun 23, 2014.

Thread Status:
Not open for further replies.
  1. bibbinator

    bibbinator

    Joined:
    Nov 20, 2009
    Posts:
    507
    Hi all,

    We would like to discuss the direction of prefabs with you. We know a lot about prefabs and their advantages and current problems, but when people talk about prefabs, or nested prefabs, it's possible it means different things to different people. So like we did in other places, we'll start with an open discussion and gather comments and feedback. One of our core developers, Steen, will participate but as I said initially we'll just have a discussion before discussing potential solutions.

    To really help us though, like we have done in other threads, it REALLY helps for us to understand who you are and what your use-cases are to put you comments in context. Especially for prefabs we need the context to better understand your comments.

    Who are you?
    What kind of game are you trying to build or would like to build?
    How do prefabs fit into that? What use-cases do you have?
    What about the current prefab system isn't working for you?

    Thanks!
    Brett
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hiya,

    To me, nested prefabs means that I can create separate prefabs which are referenced in other prefabs.

    For example if I create pilot and airplane prefabs, and the airplane contains the pilot prefab, if I change the pilot prefab's helmet to red, the airplane will contain a pilot with a red helmet.

    But if I adjust the prefab within the airplane so his helmet is blue, it will be blue, so overriding the original's properties. But I should be able to select that prefab inside airplane, and reset it so that it is red again.

    I want to be able to expland nested prefabs in the Project view, and tinker with them in there. Currently, I have to drag out my UI prefab (which contains a bunch of things) in order to change nested items within. Certainly, this is just altering the main prefab here, but it's still a chore to do since I can't navigate deep inside of it. This is a hierarchical prefab, and not what I would call nested prefabs. But I still want to be able to edit these hierarchical prefabs effectively.

    So:

    Feature 1:

    Pilot Prefab
    Airplane Prefab (contains pilot prefab)

    Adjustments to pilot are reflected in the airplane prefab, can be restored.

    Feature 2:

    Better hierarchical editing of prefabs with a hierarchy, so I don't have to drag them out or make new scenes.

    My use of them:

    I actually wouldn't use them much. This is more of an organisational thing for the designers and artists working with me. I would probably use them much more effectively for UI work, and of course where there's going to be pilots in things. It's a basic example, but I've gotten so used to working and getting along without them.

    For example I might have a reasonably large UI library eventually with our own widgets and such, and if we wanted to change these, we could just change the original prefab elements. At the moment, I have a "setup scene" to do this and apply back to the original bulky prefab. It's a bit labour intensive.
     
    Last edited: Jun 23, 2014
  3. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    Hi,

    *Who are you?

    Shkar T. Noori, CTO at Kurdify Technologies

    *What kind of game are you trying to build or would like to build?
    FPS, TPS Games [PC, Consoles (No Released titles yet) ]

    *How do prefabs fit into that? What use-cases do you have?
    Prefabs work fine on some cases, but on the other hand, they are kind of half-baked
    We use them for LOD systems , Instantiation purposes..etc

    *What about the current prefab system isn't working for you?
    Nested Prefabs, or something alike, I would like to be able to put some GameObjects in a prefab, and they become one GameObject [The Prefab GameObject] and expose some of then children's fields and values into the prefab GameObject, or simply having the ability to put some prefabs together and build another prefab, and changing the individual prefabs should change the parent prefab.

    Thanks!
    Shkarface
     
  4. MatthewW

    MatthewW

    Joined:
    Nov 30, 2006
    Posts:
    1,356
    I'm the programmer half of the two-man team making Aztez. We commonly have two big use cases for nested prefabs:

    Environment Construction

    Our environments are heavily constructed from a bunch of basic pieces. It's difficult to propagate optimizations or even simple changes to all of these pieces (layers for shadow receiving, static flags, etc). You can see a time lapse of an environment being made to get an idea:



    Gameplay Objects

    More painfully, lack of nested prefab hurts a lot when it comes to our game logic.

    Here's what an enemy in Aztez looks like at the top level hierarchy:

    Screenshot 2014-06-23 13.50.05.png

    Some of these things are specific to the enemy (the AI modes), but the other ones should really be nested prefabs (the physics sensors, blob shadow, etc).

    We could Instantiate them at runtime, but we also want to retain the ability to customize some of the settings per-character. I guess we could pass through those changes to our Instantiate script, but then we're basically doing just as much work to customize as we would without nested prefabs in the first place.

    Ideally, they would just be nested prefabs that smartly retained their overrides when we make underlying changes to the one of the root prefabs...
     
  5. Jingle-Fett

    Jingle-Fett

    Joined:
    Oct 18, 2009
    Posts:
    614
    Nested prefabs is pretty much the only thing I want off the top of my head
     
  6. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    I'm a game developer primarily working in iOS.

    A "prefab editor window" would be a fine addition (along the same lines as hippocoder's #2 point). Something where you can edit a prefab as deeply as you like, seeing the actual results in terms of placement etc, without dragging one into the scene. I'd go further and request that you be able to edit animations with this window, too.

    Second, I'd like for objects spawned from a prefab to not tack on the "(Clone)" suffix to the name. On the rare occasions that I use the GameObject's name for something in script, it's always hugely irritating, moreso if I need a script to be ready for both instantiated and pre-placed prefabs.
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's not very helpful. If anyone's reading this, please explain WHY you need them. Not "I need ice cream because it's nice."

    Explaining why will help Unity figure out the best approach to take. Case study stuff etc :)
     
    Joviex likes this.
  8. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    Oh, right, I forgot to throw in my "vote" (or whatever) for nested prefabs. MatthewW's comment is the same basic use case as I would ever use them, and made more clearly than I would be able to, so I'll let his speak for me.
     
  9. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    Who are you?
    I'm Asvarduil, a hobbyist one-man band.

    What do you build?
    I've built a starfighter simulation, cut-down RTS, and sidescrolling sword fighter (see signature). I'm currently tinkering with a prototype that is an updated version of my RTS, Zombies vs. Knights. I also have a JRPG project that is on hold.

    How Do Prefabs Fit Into That?
    Numerous ways.

    1. Basic Infrastructure - One of the things I regularly do is create a prefab of some object or set of objects united under a common GameObject, such that I can easily assemble the skeleton of a scene, and focus more quickly on the design of my projects. As an example, my projects tend to use an 'Ambassador' object, which exposes a static reference to itself, code to cause any duplicates that may get introduced to self-destruct, and code that causes the object to persist across scenes, along with similar scripts that are more specific to the genre or project in question.
    2. Game Pieces - By 'game pieces' I refer to any of the virtual artifacts in my game worlds. Less circumlocutiously, I'm talking not just about friendly, neutral, and enemy agents, but also things such as projectiles, which are added to a scene on a dynamic basis. Examples: In Zombies vs. Knights, clicking an action button on your key structure consumes resources to instantiate a game object that is bound to the button, inside of an available Spawn Sphere. The key structure also listens for enemy units to come inside of its firing range; once an enemy is inside, an invisible object will instantiate the appropriate laser bolt, which flies forward by default until it (hopefully) smacks the enemy unit in the face)
    What parts of the current prefab system aren't working for you?
    1. The inability or difficulty of programmatically defining, storing, or modifying an in-memory prefab/'game object' means that I have to spend precious storage resources and up-front development time to create variations on a standard prefab. As an example, in Zombies vs. Knights, the Knight and Zombie key structures fire laser bolts at enemy units that get too close. However, in the old project, I had to manually create a 'Zombie Laser Bolt' (the line renderer that shows the bolt haze, and the glowy central part are a red hue) and a 'Knight Laser Bolt' (ditto, except the things are blue) As a user, what I want to do is create a 'core' laser bolt (has a line renderer, default glowy shader, deals damage to units that it hits, travels forward at a given speed). My key structures should, upon their initialization, create their own in-memory copies of this core object, and alter the bolt hues as appropriate to their faction. Laser bolt fire events cause this copy to be instantiated into the game world, and the game object does the rest of its scripted work. This has greater application to my JRPG project, where upon selecting a combat option, source damage calculations would be made, the core object copied into memory, the damage amount applied to the damage source behavior on the copy, then the in-memory copy would be realized into the game world. TL;DR - I should not have to realize a game object, in order to alter properties of it.
    (Public virtual question) What does 'nested prefabs' mean to you, and does Unity need it?
    I honestly am not sure I know what is meant by that, but I'll give it my understanding up to this point.

    I always thought 'nested prefabs' referred to being able to edit a child item of a saved prefab (for instance, say I have a laser bolt prefab; the laser consists of a line renderer and capsule. It has a child, which is the damage dealing trigger.) There are (or were) some issues in Unity, where if I edited a 'child' of a core prefab in the scene, and applied those changes, it would seriously mess up the saved prefab, in some cases causing me to need to reconstruct it from scratch.

    Also, there's the limitation in Unity, that if I expand a prefab in the Project View, I can only see the first level of prefabs beyond the 'root', and none of the children from the second generation onwards. For more complex things (a humanoid prefab for instance) this makes editing the prefab from the prefab itself significantly more challenging and error prone thanks to the scene editor issue described above (which may not still be in Unity...but I haven't checked in some months. It's one of the reason I fell back to the 2D style I used in The Hero's Journey, to be totally honest.)

    Still further, I can't take a child object in a saved prefab, and just use that object. For example, if I have a humanoid Knight model with a sword that has a damage trigger on the blade, and I want to put that sword on a Zombie character, I can't take the child sword and 'just stick it in the Zombie's hand' even though it's a separate model, game object, etc.

    (Apologies for the amount of text.)
     
    Last edited: Jun 24, 2014
  10. jdyeager

    jdyeager

    Joined:
    Aug 18, 2008
    Posts:
    29
    Who are you?
    Josh Yeager, Software Developer at WisdomTools

    What kind of game are you trying to build or would like to build?
    Various game types (FPS, RPG, RTS)

    How do prefabs fit into that? What use-cases do you have?
    I agree with Hippo completely. I think I would expect nested prefabs to work basically the same way that prefabs and scenes do now. You can make changes on a prefab and have it propagate to all instances of that prefab in scenes. And you can make changes to an instance of a prefab in a scene and either apply that change back to the source prefab or leave it as a modified instance in the scene.

    The hard part seems to be coming up with how to show and manage the parent-child prefab relationship in the editor in some non-terrible way. I'm not really sure what that should look like. Maybe some expanded options in the 'Prefab' bar above the Transform component in the Inspector. And also some visual in the Hierarchy view to show that a child prefab is separate from its parent.

    What about the current prefab system isn't working for you?

    1. Having multiple prefabs that contain the same child objects because the children can't be referenced as a separate prefab (which nesting solves).

    2. Having to save my project after applying changes to a prefab because only doing the apply doesn't actually write the changes to disk. If Unity crashes sometime after I have made changes to a prefab instance in a scene and hit 'Apply', when I reopen Unity the source prefab will not contain my changes. I would expect hitting 'Apply' to actually apply my changes to the source prefab without having to also save my project.
     
    Stuart Harrison and Heisenbug like this.
  11. bibbinator

    bibbinator

    Joined:
    Nov 20, 2009
    Posts:
    507
    But it would be best if you specified what you think "nested prefabs" means :)
     
  12. ugur

    ugur

    Joined:
    Jun 3, 2008
    Posts:
    692
    Yeah, nested prefabs would be great for many things, an obvious example are UI components of course.

    A prefab is basically just a gameobject turned into a reusable blueprint so a prefab with nested prefabs would just be references to lots of blueprints so one can build even more complex reusable things =)

    Let's say one has a scrollpane which itself has a vertical and horizontal scrollbar next to a clipped panel component or similar

    The vertical and horizontal scrollbars would be both instances of a scrollbar component prefab, their scrollbarthumb could be a button prefab and the whole scrollpane would hence be a prefab with lots of nested prefabs.

    So then one could do some changes to one of the items and then ideally choose apply to this prefab or apply to nested prefab or just apply the change for a single exposed property in a script to the prefab.

    That way nested prefab support and nicely layed out setup for some core ui components would allow making lots of ui components and also adding visual and codeside quick skinning support for them.

    Then i'd also like it if it would be more clearly obvious to which prefab a gameobject in the hierarchy belongs, maybe there could be color highlighting or similar for elements part of the same prefab or some other nesting hierarchy indicator.

    Overall nested prefabs would just allow combining reusable building blocks to larger more complex reusable building blocks which can cut down on dev time a lot.

    Besides ui components themselves, i'd say the closest editing time comparable object in flash to that would maybe be a movieclip where every movieclip can have other nested movieclips in it and one can double click to edit the nested item, not sure how you'd like to highlight if at all whether one is editing the parent prefab or the nested prefab right now or one just edits it in one flow and then just sets to which item the changes should be applied in the moment one presses the fitting apply changes to... buttton.
     
  13. Jingle-Fett

    Jingle-Fett

    Joined:
    Oct 18, 2009
    Posts:
    614
    Aaand that's what I get for skimming through the OP's post and not reading it all the way, derp (I thought bibbinator was talking about prefabs in general and didn't see what he already said about nested prefabs).


    Who are you?
    VFX artist, 3d artist, developer

    What kind of game are you trying to build or would like to build?
    Scifi 2.5D platformer with visuals aiming on the high end side

    How do prefabs fit into that? What use-cases do you have?

    In my game BHB, I have a large number of enemy alien characters. Most of them when they die, they instantiate a death prefab containing a bunch of gibs. The way I build the death prefab is I have a series of individual gib objects as prefabs which explode after a short time. But the gibs aren't the death prefab itself, the actual death prefab is made up of many game objects, including multiple gib objects. The death prefab will contain multiple gibs, particle systems, and more. The problem is, if I want to change say the lifetime of the original gib prefab to improve peformance, I have to go in to each individual death prefab using that gib, and adjust the lifetime of each individual gib. Having to do this wastes time, and limits the possible number of death prefabs for the sake of keeping things manageable.
    This is especially problematic because some of the enemies spawn multiple smaller enemies on death. If I want to change the stats or anything of the original little enemy, I have to go back to all the death prefabs containing the little ones and adjust all their stats too. None of this would be a problem with nested prefabs.

    (example of the enemies spawning little enemies on death)


    Some of the enemy alien characters also fire projectiles and we get the same problem. Some of the projectiles are made up of multiple objects that I reuse (particle systems, lights, etc.). Some of the projectiles explode, spawning other projectiles (like a cluster bomb). If I want to go in and adjust the stats of the individual cluster bombs (damage, explosive force, etc), I have to track down every object using that bomb to make sure they all have the same stats. Ultimately, lack of nested prefabs makes it very difficult to reuse game assets in new ways.
    This also applies to complex enemy characters that might have prefab objects attached to them. For example, one of the simpler enemies has multiple identical particle systems attached, and I might have multiple versions of that enemy in the game, adjusting the particle systems for each one and keeping them all the same takes forever.

    The game also contains traps and some of the traps are objects made up of other objects. For example, one such trap is a giant spinning prefab object that has lasers attached. These lasers get reused in many places in the game and this particular object has 12 attached. And I place many of these spinning objects in the game.
    Each laser has it's own sounds, particles, etc. as child objects. So if I want to make a change to the laser object, I have to go through each individual object that uses a laser, and make changes to every single one. This adds up very quickly and that's a lot of time spent doing something that would be trivial without nested prefabs. I might also have variations of the spinning object too or one-off "break prefab instance" versions, so then we have to adjust the lasers there too.
    We basically have a prefab, containing a prefab, containing 3 prefabs, and each of those 3 prefabs contains 4 laser prefabs. And while it plays and behaves fantastic, it's a pain in the butt to maintain and adjust. These sorts of objects would be easier to work with if we had nested prefabs

    (skip to 2:10 to see the laser object in action).



    What about the current prefab system isn't working for you?
    Lack of nested prefabs, without them it's hard to maintain as game complexity grows. Another thing that is extremely annoying is the fact that when you have a prefab sitting in the project panel, you can't explore the prefab's whole hierarchy. You can only go down one level in the hierarchy, which means you HAVE to put it into your scene (instead of being able to do quick edits directly in the project panel). So for example, if you have a gun object attached to your character's hand bone, you can't adjust that gun without dragging/dropping the character into the scene.
    And like others have suggested, having some sort of prefab editor similar to the sprite editor would be really nice (where it opens its own little window containing just that object so you can make your adjustments without having to put it in the actual scene).
     
    Last edited: Jun 24, 2014
    hippocoder and Heisenbug like this.
  14. Heisenbug

    Heisenbug

    Joined:
    Aug 31, 2012
    Posts:
    40
    Who are you?

    M.Oliviero - Programmer

    What kind of game are you trying to build or would like to build?

    I target mostly mobile platforms (iOS, Android, WP8). The last year I developed a 3D parkour running game and now I'm working on a stealth game.

    How do prefabs fit into that? What use-cases do you have?
    What about the current prefab system isn't working for you?


    Prefabs are a great feature but unfortunately, the lack of nested prefabs make them not so useful.
    What I intend for nested prefab is exactly what hippocoder said in his post.

    I had at least 2 use case scenarios from my last game:

    1) Level editing

    It would be really useful in order to dramatically reduce level editing time and refactor, to build scenes using hierarchical structures.

    Just a concrete example: let's say I have to layout a city environment.
    The artists decide to arrange in several zones of the scene some typical street elements.
    Let's say they create a prefab A with a row of 3 street lamps.
    Then they create a prefab B: a square with several benches and trees, and a row of prefab A on each side. They'd like to create prefab B because they want to reuse this pattern across different scenes.

    Now if they do that they'll have a prefab B that as a child A, but unity doesn't support nested prefabs so if they decide to change something (es. the relative distance from each street lamp) they can't modify A and propagate it to B.

    For complex environments this quickly become a nightmare. Of course they can change workflow, and not use prefabs or not build hierarchies with different prefabs but this way sharing patterns across scenes becomes problematic.

    2) Complex hierachical GameObjects(with serialized properties)

    In the game I'm working right now there are several different kind of enemies. They all have very specific behaviors, but a lot of them shares common objects.

    For example, there are several kind of guards, and some of them share the same kind of view cone.
    The view cone isn't simply a graphic component but it's a complex objects with a lot of elements(es.compound colliders, graphical components, customizable list of parameters that determines how they interact with the player and the environment and so on... ).

    Now the guards MUST be a prefab, I need to share them across scenes and I want to maintain a link to a prefab in order to be able to update their specific parameters to all instances (es. game designer decides they move to slow, increase velocity on all guards of type A).

    Now guards of type A and B have different behaviors but they share the same exactly kind of view cone, what to do?

    1. Not use a prefab for the visual cone and store parameters somewhere else and init them at runtime. It could be done, but requires code and the workflow become more complex for non programmers (game designers should edit config files instead of simply tweak parameters on the child prefab and click apply)
    2. Use a prefab for the visual cone. Then every time I update a serialized property every guard's prefab who has it as a child cone must be manually updated. Long, prone to bug, unfeasible if the combinations between prefabs increase.

    Conclusions

    Of course it depends on the workflow, the team and the kind of game, but been able to rely on a built-in hierarchical prefab system would be a major improvement (time, ease of use, maintainability).

    Side notes:

    I wrote just a couple of examples but I have really more complex use case scenarios I can talk about.

    For my previous game I had to implement a custom system for support prefab hierarchies. It worked, but it have serious drawbacks in particular:

    • doesn't support property overrides
    • long time to update deep prefab hierachies
    • not transparent to the user (required knowledge of how a prefab is positioned inside the hierarchy: es.internal node ore leaf? doesn't work with simply drag and drop operations, ...)
    Despite the problems the systems save our lives in several occasion, but it was so complex that I simply decided to not use it for the new game (we have been forced to change workflow and do a lot of operations by hand).



     
    Ostwind likes this.
  15. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Who are you?
    I'm a programmer working in a two-man team with my brother (a 3D artist). Our background is in flash game development, and we are still developing flash games occasionally.

    I mention flash, because flash has movieClips - a similar concept to Unity prefabs. You can create/design a movieClip object and then instantiate it into the scene. Changing the original movieClip affects all it's instances. The most important part is that you can nest movieClips (add instance of movieClip "A" as a child to another movieClip "B" and still have that child instance retain its link to the original movieClip "A").

    What kind of game are you trying to build or would like to build?
    Mobile FPS games, 2D arcades, etc.

    How do prefabs fit into that? What use-cases do you have?
    I'm using prefabs to store custom UI widgets, such as buttons, windows, message boxes, panels, etc.
    I'm also using prefabs for level design, where a certain object with specific functionality and look can be saved as a prefab for easier re-use in more complex scenes, or when multiple instances of an object are required.

    What about the current prefab system isn't working for you?
    I mainly have 3 issues:
    1. UI elements: I designed a button, saved it as a prefab. Then I designed a window / panel / message box and saved it as a prefab as well. If that window / panel / message box had the button prefab instance as its child, the moment I save that window as a prefab, the button instance loses its connection to the button prefab. If I drag another prefab (a checkbox) into the same window / panel / message box prefab in the Hierarchy window, the moment the checkbox instance is create as the child of the window it also loses the connection to the checkbox prefab. If I later decide to change the background color of both the button and checkbox prefabs, the window / panel / message box won't be affected.

      Same goes for environment / game objects: I have a bouncing ball prefab. I want that ball to sometimes be on a moving platform. If I make this ball the child of the moving platform and save the platform as a prefab, the ball instance loses connection to it's prefab. When I decide to change the height of the bouncing ball in the ball prefab, the ball on the platform is not updated.
    2. Prefab editing. In flash you can edit movieClips in 2 ways:
      - Double click the movieClip in the library ("Project window" in Unity) and a blank scene is opened with just the movieClip contents. You can edit the movieClip however you want and then return back to your main scene.
      - Double click the movieClip instance in your main scene and all unrelated objects become semi-transparent, so you can more easily see and edit your movieClip. This works the same even for nested movieClips, so you can go editing as deep as you want.
      I'd really wish to see a similar way to edit prefabs in Unity: Double click the prefab in Project window and a temporary blank scene opens up with just the prefab contents. Double click the prefab in Hierarchy / Scene view and all objects except the prefab contents go semitransparent.
    3. There is no way to properly break a prefab link. I have a prefab instance and I want it to take it's children and have them lose their connection to the prefab. I can't do that. Even when I click the break prefab connection, I'm still having the "apply" "revert" buttons at the top and I'm always afraid I could press that button and ruin the scene. I want to be able to break the link once and for all.
     
  16. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,614
    I just want to say that what Hippo said here pretty much sums up my thoughts, except for the part where he says he might not use it a lot - pretty sure I would use it in plenty of places, and save a fair bit of time. Modular level design and GUI styling immediately spring to mind.

    I also like StarManta's idea of a "prefab window". Sometimes it can be a bit of a pain to have to add something to your scene just so you can change it. Though I accept that in those cases the same thing that makes it a pain could also make it really hard to implement a separate editor - like ExecuteInEditMode doing stuff, or NGUI stuff auto-adding a UIPanel if it can't find one in a parent, and such. It'd be a nice-to-have, but it's not important if it comes with too much engineering cost and/or lots of obscure gotchas. (For instance, with the NGUI thing, if clicking the prefab showed it in a prefab window, which caused its scripts to run, which caused the UIPanel parent to get auto-added... that would be bad.)
     
    AndrewGrayGames and hippocoder like this.
  17. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    Hello everyone,

    So to sum up for now:


    • Nested prefabs: As in being able to reference other prefabs from one prefab
    • Prefab editing without having to instantiate the prefab in the scene
    • Saving of prefabs immediately after editing
    • Improved breaking of prefab link
     
    AndrewGrayGames and Gigiwoo like this.
  18. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    I would also add:
    • Applying singular prefab fields (just like reverting singular prefab fields)
    to that list. A minor improvement, but pretty useful.
     
    Heisenbug likes this.
  19. ChrisPruett

    ChrisPruett

    Joined:
    Aug 16, 2012
    Posts:
    1
    Hi, I'm Chris from Robot Invader. We make pretty cool mobile games for iOS and Android. Our most recent release is Wind-up Knight 2.

    Most of our use cases and requests have been covered already. We use prefabs heavily for UI work, and not being able to separate individual elements from prefabs of entire screens is really cumbersome. In one of our games, Rise of the Blobs, we ended up making a special ColorSwatchManager so that we could edit the standard colors of our buttons across the entire game without having to change each individual panel prefab (of which there were many).

    Just in case: my understanding of a "nested prefab" is a prefab that maintains references to other prefabs that represent subtrees. These subtrees may themselves have fields that are the default from the source prefab or overridden by the parent prefab. This sounds great.

    A couple of use cases / problems we have that I haven't seen mentioned yet.

    We often use prefabs in leu of scenes. Scene loading is very slow on mobile devices, and it's difficult to control the output of a scene load (i.e. you can't additively load a scene and append its children to a specific game object parent), so we move things we need to load dynamically into prefabs and instantiate them instead. We also do this because we work with source control and scene files are neigh impossible to merge. By splitting everything into prefabs, even when we only need one of them, we can edit the game simultaneously and only need to worry about collisions of individual prefab files (which is pretty rare). This workflow is sort of a hack around the slow scene loading problem; we generally want to load a scene as infrequently as possible. Rise of the Blobs is all implemented in one scene.

    Along the same lines, loading a scene that contains prefabs appears to be much slower than loading a scene that does not. We try to optimize our boot times, for example, by making our first scene have no prefabs and as few external resources as possible.

    Finally, we're not big fans of the way imported meshes are treated as prefabs. It makes sense until you put an imported mesh into a prefab, then update the FBX to discover that your prefab is pointing at new meshes but still retains the old object hierarchy from the previous import. This is almost never the correct behavior, and working around it has a lot of implications in our work flow (we try to never attach scripts or colliders to mesh objects that we plan to change, since we'll have to rebuild them if we change the FBX). Another aspect of the "nested prefabs" feature we'd love to see is to have bits that come from FBXs retain their link to the source FBX, even after we've put them into another prefab, and even if the hierarchy may change in a subsequent import.

    Hope that helps!
     
  20. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    218
    What kind of game are you trying to build or would like to build?
    I'm building a theme park business simulation, think something along the lines of Theme Park/RollerCoaster Tycoon.

    How do prefabs fit into that? What use-cases do you have?

    In my game the player can place different things in the game world, e.g. paths, rides, food shops. I'm using separate prefabs for each thing the player is able to build, e.g. for each type of food shop. My prefabs usually have multiple scripts on them with a lot of settings (e.g. references to a food prefab sold by the shop, price of the food, references to sub-transforms of the prefab...).

    What about the current prefab system isn't working for you?

    This is by far the biggest issue I have with prefabs - they aren't very friendly for iterating on art. Let's say I made a prefab from a model containing multiple meshes, put my scripts on there, made my settings - if the model changes (adds/removes meshes, changes their orientation/rotation) the prefab is broken/doesn't reflect the new art and I have to remake the complete prefab.
    A significant amount of my development time is just redoing prefabs over and over again, it is boring and annoying and error-prone since you easily forget to transfer one of the scripts or its settings.
    I imagine updating prefabs automatically when the art changes could be difficult, so if that doesn't work I'd like to have a quick and easy way to transfer all my scripts and their settings between prefabs (ideally, even everything I set manually on a prefab, like the layer, mesh renderer materials, ...).
    That'd instantly fix my biggest issue with prefabs.

    Apart from that, what others already said: being able to apply/revert singular prefab fields, nested prefabs (have one prefab as the child of another, if you change the child it also changes in the parent) would be nice-to-have for me, but no priority.
     
  21. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,614
    Yeah, actually, I echo this. I have no idea how to suggest it is rectified, but I agree it's an issue.
     
  22. StephanK

    StephanK

    Joined:
    Jul 10, 2012
    Posts:
    47
    I'm a mobile game developer and we are are currently working on a lot of different games in various genres.
    Prefabs are very important to us and we use them a lot to instantiate stuff at runtime and also to keep complex games maintainable and avoiding conflicts. Our main issue with the current system is that we can't have "prefabs of prefabs" (aka nested prefabs). This would be extremely useful as this would be an efficient way to work around the problem of "non-mergable" scenes. (I know that this is possible in theory, but in praxis this never worked and introduces some horrible workflow issues if you try to...)
    A common use case would be having ui pages/popups as prefabs while still using button prefabs on them. Another thing that is annoying with the current system is that in complex scenes it's not easy to spot overrides and in some cases these are not even displayed correctly (no bold case). A better display for this would be very handy (maybe similar to how TortoiseSVN marks changed folders in your file browser). It's also a pita that you can only revert whole prefabs (or components). I would like some more fine grained control that allows you to check/uncheck specific parameters as override. Maybe there could also be a special Inspector that shows you just the overridden parameters on a prefab (and its children).

    Also the way the current PrefabUtility updates prefabs is not very useful as it will change file ids within the prefabs and then all overrides and references to prefab instances are broken.

    Actually the current prefab system is the one thing that gave me the most headaches since I started working with Unity (6 years ago) so these improvements would make me a happy man after all. ;)
     
  23. Wahooney

    Wahooney

    Joined:
    Mar 8, 2010
    Posts:
    281
    I'm a member of RetroEpic, most of my time is spent programming and setting up prefabs/systems for our layout guys to start arranging levels.

    Currently working on a puzzle physics platformer.

    The kind of nesting I'd love to see is similar to symbols in Flash, where a complex object is collapsed into a simple single object, which obviously can be nested. Nested prefabs were shown off as a WIP in a Unite tech talk some years ago where properties were exposed to the upper level of the prefab, and those could be exposed to a higher prefab, etc. That would be great! As sometimes it's difficult to prevent LDs from modifying potentially game breaking values and hunting those issues down can be nightmarish.

    For a long time I've really wanted an attribute on MonoBehaviour fields that could prevent that field from being applied when the prefab is applied, this will prevent cases where you want to apply some value changes on a prefab, but not others. This system could be realised with a context menu item similar to the "Revert Value to Prefab", you could have an "Apply Value to Prefab" option, which could be per field and per component.

    A method to completely sever the connection to a prefab would also be great :)

    EDIT: The ability to apply multiple prefabs would be lovely too :D
     
  24. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    Who are you?
    A Senior VR Developer at an E-Learning company based in the UK

    What kind of game are you trying to build or would like to build?
    We build interactive E-Learning programs for a variety of major industries using Unity.

    How do prefabs fit into that? What use-cases do you have?
    Prefabs are mostly used to keep certain pieces of our programs standardised, or to transfer parts of a hierarchy to other projects. These use cases don't matter much when taking into account what we would like to do with Prefabs.

    What about the current prefab system isn't working for you?
    In order to streamline our workflow and initial project setup, we attempted to use an assetpostprocessor on our FBX imports. The way we wanted to use this was to set up scripts and other components on our imported Prefab. We ran into problems with the fact that adding components to these import Prefabs is not currently allowed.

    We stopped investigating this solution once that was discovered, but it really would be of great benefit to be able to attach components (mainly scripts and their initial properties), to the import Prefabs via the Post Processor. There are many uses we have for such a system that would really speed up our initial project setup times.

    Edit: To clarify, we are using Unity 3.5.6, I suppose the way these import Prefabs work may have changed, if so, you can disregard this suggestion.
     
    Last edited: Jun 24, 2014
  25. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Who are you?

    Nicholas Francis, Unity founder

    What kind of game are you trying to build or would like to build?

    Hi production-value tablet real-time tactical shooter. Thinks Syndicate meets XCom. framebunker.com for more info.

    How do prefabs fit into that?
    We are a small team, so we are very focused on optimal production paths.

    One of our continued points of breakage early on was due to lack of nested prefabs. Best explained with an example:

    The artist made a turret. It needed quite a few scripts attached to it at various points in the hierarchy. We would take the imported FBX file, add scripts and create a new prefab that we would place in the level. Later, the artist modified the FBX file, and our turret would lose meshes, have missing objects, etc.

    As part of that, we have an in-house implementation of nested prefabs that's pretty much what I demoed at the Unite keynote some years back. Our solution was to make a PrefabInstance component, that causes an instance of a prefab to be instantiated at that point in the hierarchy. A prefab can have a property sheet which defines which values are tweakable in the instances.. Say you have a Button prefab (that has tons of components). This would publish a 'text', maybe an 'image', maybe the text color. Each prefab instance can then override those values & only those values. We use SerializedProperties to achieve this.



    What use-cases do you have?
    • Our artist can tag an object in his max-file as "Prefab:prefabname". Then prefabName will get added to the importer model at the location of the tag. This is used for decorating stuff like:
    • Insert lamps into the model. The 'Lamp' prefab publishes lamp color, range & a few other options.
    This means that the artists can make a streetlight and have it come into Unity with a proper shadowcasting spotlight attached

    • Add cover points so e.g. a crate is fully marked up and ready for gameplay insertion

    • Our artist can have root-level components from a prefab added to an imported model. So the artist can add a RotateScript to a fan in a piece of environment art, and it will all just work. Here, the 'rotation speed' is a published value, so we can tweak.

    • For more advanced stuff (say a character), we have a standard Unity prefab, that contains all scripts & configs. The art gets pulled in via a PrefabInstance, so if our outsourced modeller adds a goggle gameObject or joins some meshes in the fbx for performance, the actual prefab we insert into all our levels never changes. In this case we use scripting to get to all the attachment points.
     
    Sycobob and laurentlavigne like this.
  26. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I am not exactly sure how much you simplified the nested prefab case in this summed version. But I would like to point out that referencing alone will not be sufficient, because custom overrides and extensions to those referenced prefabs will still be needed.

    Who are you?
    Freelance developer

    What kind of game are you trying to build or would like to build?
    The applications are pretty conventional ones, but as usual, it is necessary to have efficient workflows where nested prefabs would be very handy.

    How do prefabs fit into that? What use-cases do you have?
    As a use case I am taking the UI, which is by far the most obvious one in my opinion. Let's assume we have a button prefab. It would be awesome to reuse it in various contexts.

    What about the current prefab system isn't working for you?
    • Use the button e.g. in a dialog prefab. There may be an okay and a cancel button with custom label texts and both with a custom script which is responsible to react to the click event. Changes made the original prefab should certainly be reflected on those button prefab instances as well.
    • In the dialog prefab, the buttons may also have some more child objects that are only displayed as e.g. the mouse is over the button or when it is pressed.
     
  27. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,105
    Who are you?
    Console, Mobile, PC game developer

    What kind of game are you trying to build or would like to build?
    Mobile Runer, FPS

    How do prefabs fit into that? What use-cases do you have?
    First is simple create prefab from model. After importing model it just not usable, we need add some components to it, tune it... and create prefab for LevelDesigners. After that if model will change in future our newly created prefab break!
    So we need to recreate it by hand.

    Building some complex objects is complitly impossible because placing prefab inside other prefab don't work, work only for ONE place in ONE scene, trying to use it in multiple places of cross scenes not possible with Unity prefabs.

    UI, there many posts above about using nested prefabs in UI.

    What about the current prefab system isn't working for you?
    Now Unity just don't have nested prefabs/prefab inheritance and all work with prefabs is broken.

    I want not only nested prefabs but prefab inheritance!

    Not only nested but INHERITED! Be able to inherit one prefab from another and change inheritor i.e. change properties, add/remove components/gameobjects.

    Prefab Evolution is the best solution for prefab inheritance:
    http://forum.unity3d.com/threads/prefab-evolution-plugin-nested-prefabs.236719/

    just add all features of it into Unity prefabs.

    But I want editor UI and editing nested prefabs like you do in 2012:
    at 58:04

    time link: youtube.com/watch?v=24AY4fJ66xA&t=3483
     
    Last edited: Jun 24, 2014
    shkar-noori likes this.
  28. ugur

    ugur

    Joined:
    Jun 3, 2008
    Posts:
    692
    Just wanted to say that i talked mainly about unity in scene made prefabs and how nested prefabs would be useful there, but i totally agree with Nicholas Francis, generating prefabs from or using models one imported is another very important even if different setup use case.
    Right now when i deal with models i always don't put scripts and gameobjects on them in their hierarchy, instead i put the model into a container gameobject which contains the scripts and then if i need to put something into the model's hierarchy itself (like let's say colliders or particle emitters or whatever) i do that on codeside at runtime.
    Why?
    Because else, like Nicholas explained nicely, when one would add scripts or other gameobjects etc on gameobjects making up the model's hierarchy and then would want to update the model later, that breaks everything.
    So it would be very good if that use case, which is actually very common in games, that one wants to put stuff onto a model or somewhere in his transforms gameobjects hierarchy, that would not break the prefab connection.
     
  29. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Who are you?
    Simutronics Corp. Over 30 developers, 27 years making games. Over 3 years with Unity.


    What kind of game are you trying to build or would like to build?
    Many games, but we are currently working on a large, high profile, marquee franchise title for a top publisher.

    How do prefabs fit into that? What use-cases do you have?

    Prefabs are the #1 issue we face when working with Unity. Improvements to Prefabs would have more impact on us than a new GUI system, new renderer, or anything else that is contemplated. I cannot over state the significance of how the current prefab system bedevils our workflow.

    We are a good sized team, of about 25 developers, artists, designers, etc. And that does not include external resources of the publisher.

    Issue we run into:

    1. Nesting

    The #1 issue is, as others have noted, the lack of proper nested prefab support. We rely heavily on prefabs and the nesting of them. Our current project has no visible things in the scene as everything is created dynamically from prefabs.

    Much has been said about this already. The solution shown at Unite 2012 is almost ideal. It only had one flaw I could see: If you had multiple properties with the same name it was hard to tell which was which during the rename process for the exposed designer properties. Pretty much a small matter easily resolved.

    But, in short, that's the thing we need.


    2. Lighthmap (and other) Support

    Current lightmapping is linked to the scene. We models in prefabs to have their lightmapping retained. In our current project the environment is dynamically generated at runtime (and it is all ligthmapped from within Unity). Currently we have to do some serious convoluted stuff to make this work.

    This extends to other areas where things are stuck at the scene level and we need them at the prefab level. Such as Light Probes. Navigation data, etc. Every time this happens we get stuck and have to find some very non-optimal way around it.


    3. Better Merge Support

    The text syntax for Prefabs is hard often hard to deal with in version control scenarios. Same problem with the scenes, since they use the same approach. You can technically merge changes to them, but it is a brain buster to do it and sometimes for all practical purposes impossible. The only way we deal with this now is by managing exclusive editing of prefabs with the entire team... an error prone and tedious process that discourages agile efficiency.



    Again, the nesting of prefabs is the all-consuming issue we face on virtually everyone one of our projects. It is the top pain point in Unity from our perspective. It is encouraging you are asking about what can be done, but honestly you've known for a long time.
     
    StephanK and Heisenbug like this.
  30. knunery

    knunery

    Joined:
    Feb 22, 2014
    Posts:
    11
    Who are you?
    Mobile developer.

    What kind of game are you trying to build or would like to build?
    Endless Runner

    How do prefabs fit into that? What use-cases do you have?
    I have about 50 prefabs where the next part of the level is randomly generated by picking one of these 50 prefabs. About 80% of the objects contain coins. The coin object is fairly complex with scripts and an animator controller, etc...

    What about the current prefab system isn't working for you?
    If I need to make a change to the coin object I have to go to 40 prefabs and update the coin child object. To me "nested prefabs" would fix this issue by allowing the 40 prefabs to share a coin prefab.
     
  31. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    One thing I'd really like to see in the hierarchy is some indication of which prefab each GameObject belongs to, as well as whether a nested prefab is referenced by its parent prefab, or has just been added later. Maybe like this: Nested Prefab View.png
     
  32. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It'd get interesting once cyclic nesting is introduced, so some way of dealing with that would have to be elegant.
     
  33. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Unless you've got an amazing use case, I think the best way of dealing with cyclic nesting is to prevent it.
     
    AndrewGrayGames likes this.
  34. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    This covers my use cases and as others have provided great explanations, I'll just add, "Yes Please."

    Gigi
     
    AndrewGrayGames likes this.
  35. camposanto_will

    camposanto_will

    Joined:
    Dec 11, 2013
    Posts:
    4
    *Who are you?
    Campo Santo, an approximately 10 person game studio.

    *What kind of game are you trying to build or would like to build?
    We are working on a First-Person exploration and story game. Our game world is large enough that we are loading and unloading bits of it dynamically. The scale ranges from huge forest vistas to small, intimate spaces full of intractable objects.

    *How do prefabs fit into that? What use-cases do you have?
    We use pre-fabs for two major purposes right now.

    1) Functional. We want to place jump or climb points in lots of places in the level. We can set them up, then just move them around, place them where needed. This is mostly done with interactive objects.

    2) Organizational. With several people working in a scene file at the same time, we often want to make things Prefabs just so they are easier to merge / work with. Very quickly we determined that merging scene files was too error prone to work long term. So we try to keep logically distinct areas of our game off in prefabs to allow simultaneous work.

    *What about the current prefab system isn't working for you?
    The inability to nest prefabs is a constant problem.

    If we want an interactive object to contain another interactive object, art prefab, or organizational prefab, we have had to come up with workarounds. We currently have some code that allows us to spawn and despawn a prefab from within a prefab that gets us most of the way there. However, editing it and dealing with its memory is not ideal. It is also far more complicated to remember to place a dummy object, set up the prefab spawner component, and then wire it to the correct .prefab then it would be to just place a prefab.

    We even have this problem with art assets. If our environment artist loads up an art asset with several meshes inside of it, say CUBES.fbs containing both CubeA and CubeB, those assets will not get updated properly if they are inside of a prefab. Proper prefab nesting should fix this, I would imagine.

    This nesting would necessitate another useful fix, showing multiple layer of prefabs in the Project Browser. Right now you have to drag a prefab into the scene view if you want to view / access nested prefabs. This has been previously mentioned and excellent mock-ups have been made.

    We often find that we want to make 'variants' of an existing prefab. Say, for example, that we have a Wine Bottle you can pick up and look at. Ideally, we would be able to get that tuned, then create a Whiskey Bottle by starting from the Wine Bottle, creating a new prefab based on it, and then altering a few properties, much like an instance can vary from its prefab parent. If we later need to make changes to both, we could alter the Wine Bottle parent. The mesh override in the whiskey bottle child would remain untouched.

    This would let us rapidly produce visual variations for logically similar objects, without incurring massive maintenance costs as the logic needs to change.

    Ideally, this would work by letting you set a 'parent' field on all prefabs that sets this inheritance. If, later, it became necessary to remove this inheritance, you could simply clear the parent field.
     
  36. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    Who are you?

    Ralph Barbagallo. Founder, FLARB LLC (www.flarb.com)

    What kind of game are you trying to build or would like to build?

    A VR game.

    How do prefabs fit into that? What use-cases do you have?

    I have interfaces that both are built into the level in 3D and can be instantiated in front of the camera as a pop-up.

    What about the current prefab system isn't working for you?

    The interfaces are each prefabs under an interface manager prefab object. Changes I make to the individual interface screen prefabs aren't reflected in the versions of the interface that are physically placed in the scene since they are nested under another prefab.

    It's really a workflow issue. I'd like to be able to have nested prefabs so I can change small parts of a larger prefab and have it reflected in the rest of the scenes that contain it. I've had this issue with a lot of projects. Case in point--an infinite runner where the pre-defined level chunks are prefabs, which contain monsters that are also prefabs. But changes to the monster prefabs don't change the monsters in the level chunks since they are nested prefabs.
     
  37. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Repeating my thoughts from an earlier thread:
     
  38. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Exactly what I was thinking. Cinema 4D does this with their instance objects and it's never been a problem.
     
  39. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    I know in code, there are rare cases where cyclic dependencies are useful, but in all of those cases they are controlled (e.g. if your system detects a cyclic loop twice, stop cycling.)

    Has anyone ever encountered a case where cyclic dependencies of prefabs are useful for any real reason?
     
  40. Alessaint

    Alessaint

    Joined:
    Mar 21, 2011
    Posts:
    43
    *Who are you?
    Ales Ulm, Bohemia Interactive

    These pretty much cover everything we would love to see improved :)
     
  41. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Hi. I'm me, currently working on a mobile puzzle game with a small team and a PC FPS with an even smaller team.

    My idea of nested prefabs is basically the same as hippo's, but I would add:

    - Altering the nested pilot within the airplane in the project view (or in scene and pressing apply) would only apply those changes to the prefab version in the airplane.

    - Altering the unnested pilot in the project view (or an instance in scene and pressing apply) would apply the changes to all nested prefabs in other prefabs, but would only modify properties that were still default in those prefabs. So if pilot prefab starts out with a red cap and red pants, then you change the nested airplane's cap to blue but leave his pants alone, then go back and change the base pilot prefab to have green hat and green pants, you now end up with the nested airplane pilot having a blue hat but green pants.

    I realize some people might have different ideas of what should happen in that case, but I think that should be the default and would work in all the use cases I have run into. You could add a bunch of buttons to have prefab changes propagate in some other manner if you wanted.

    Use case: In our mobile game, we use NGUI and the lack of nested prefabs there hurts. For example, we had a button prefab, and it was in some window prefabs, and then the UI designers wanted to change the way all the buttons looked, but the change wouldn't automatically propagate to any buttons within window prefabs, so they had to manually go through and change them all. I got around it by attaching a component that would take a reference to a prefab and copy the important properties to itself on awake, and put that all over the place on sub-prefabs, but it's clunky.
     
  42. Tenebrous

    Tenebrous

    Volunteer Moderator

    Joined:
    Jul 25, 2011
    Posts:
    102
    Simply put, I would really love that the prefab system shown by Nicolas in the 2012 actually saw the light of day. I think that solves a lot of people's problems, including nested prefabs.

    Video: Link
     
  43. spectre1989

    spectre1989

    Joined:
    Oct 6, 2009
    Posts:
    125
    Who are you?
    Joe Best, programmer at RedBedlam

    What kind of game are you trying to build or would like to build?
    In the past - an MMO client, an educational game, various prototypes.
    Currently - an FPS.

    How do prefabs fit into that? What use-cases do you have?
    Anything that I don't want to copy and paste in the editor is a prefab, or if I want to instantiate something dynamically then it'll be a prefab. Also if I have many instances of something, then I want to be able to change values on one, and have those changes propagated across all the others.

    What about the current prefab system isn't working for you?
    As everyone else says - nested prefabs. If I make a prefab out of other prefabs, I want to be able to choose whether I am copying that Prefab A into Prefab B, or whether prefab B is just containing a reference to prefab A. That way if I have a bunch of different prefabs of buildings, all containing many windows which are also themselves instances of a prefab, if I want to fix something on all of them I need only edit the window prefab.

    I understand the issue with this is how to communicate to the user whether a gameobject in their Prefab A's heirarchy is actually part of Prefab A, or just a reference to Prefab B. I believe this could be solved very easily by just putting a symbol next to the gameobjects name in the heirarchy which means "this is a reference". Then you can see it at a glance, and it shouldn't be too confusing.

    Ultimately though, you shouldn't really need to ask, people have been asking for nested prefabs forever! How long has Unity been around now? 9 years? Get your (not you personally) act together! In what Universe is shiny bells and whistles like mobile-god-damn-shadows and DirectX 11 more important than fundamental engine features like prefabs?! /rant
     
  44. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    The prefab system breaks with skinned meshes setup. When the fbx is updated, the whole prefab is broken. That means I have to resetup the gameobjects attached to the bones again.
     
  45. Flimsy-Firewood

    Flimsy-Firewood

    Joined:
    Aug 23, 2013
    Posts:
    1
    Who are you?
    Ilya Bossov, Senior Game Designer at Turbine, Inc.

    What kind of game are you trying to build or would like to build?
    Can't talk about it :)

    How do prefabs fit into that? What use-cases do you have?
    We use prefabs extensively, for game objects and UI elements. We have a large mega-UI-object-filled-with-prefabs-within-prefabs that is copied into every scene, but with data-driven modifications. We can't hit "apply" to this object because data in each scene is slightly different and it will break other scenes. When bugs are fixed in this object, they need to be fixed in all the scenes individually because we don't have nested prefabs.

    If nested prefabs become a reality, I would suggest altering their color (i.e. purple instead of blue), indicating that the object is a nested prefab and that hitting apply to it would change all instances of that nested prefab and not the parent prefab.

    What about the current prefab system isn't working for you?
    Dragging and dropping across multiple panels is a major source of headaches. The UI is not responsive enough to drag a prefab into a script window, resulting in unwanted parenting, movement, duplication, entire project trees being shuffled around. As you drag the prefab across the screen, it's entirely unpredictable when it decides to "drop" from the mouse cursor, even though the button is firmly held down. On occasion the mouse can even pick up a different object and you keep on dragging it to its destination to fail. When a scripts needs an object to fill its variable, it takes 5-7 tries to dunk it in there, punctuated by careful reversal of all the accidental damage caused to the project tree.

    I understand that some Unity addons further degrade the ability to drag and drop (ProBuilder, ProGrids), but that might be a superstition at this point.
     
  46. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    @Flimsy I've never seen this problem you describe with dragging prefabs. And we use virtually nothing but prefabs! Can you post a screencast of that?
     
  47. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Three ideas.

    Templates - What if prefabs could have templates, just like the colour selector has the ability to save colours for reuse could prefabs have setting templates. If the prefab is the hierarchy of objects and components then a template is the settings within that hierarchy

    Branches - What if you change the structure of a prefab and Unity gives you the option to branch a new prefab.

    History - Ability to Undo Redo all previous versions of a prefab it's Templates and Branches, like a mini version control system.
    .
     
  48. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,221
    Elefantopia here, finishing McDROID

    Here is the summary: We need what Nicholas showed at Unite 2012: in-scene nested-prefab editing.

    Current workflow is this:

    We maintain a large scene with all the prefabs "blueprints", that scene is called _PREFABS.
    When we tune something in-game we then copy the thing we tune, load _PREFABS, paste the object then copy and paste the values.
    If by mistake we 'apply' one of the blueprint and then save the scene, we need to restore the _PREFABS scene from the asset server.
    MC, our sound guy, came on board 4 weeks ago. It took him 1.5 weeks to get used to that workflow.
    If I change the hierarchy a little in the 3D asset, the prefabs looks invisible so I need to load _PREFABS and apply the prefab blueprint.

    In addition:
    - the slightly blue look on prefabs is hard to read, need to be more obvious.
    - we need to see how things are referenced within the scene and between scene and Projects. like a translucent node graph overlayed on top of the 3D scene, linking hierarchy, inspector and projects. This is very very important.
     
    Last edited: Jun 25, 2014
  49. Lithel

    Lithel

    Joined:
    Mar 8, 2014
    Posts:
    1
    Who are you?

    Programmer on a midsized RTS team working closely with designers and artists

    What kind of game are you trying to build or would like to build?

    Current project is a Real Time Strategy game.

    How do prefabs fit into that? What use-cases do you have? What about the current prefab system isn't working for you?

    We make extremely heavy use of prefabs in the game since pretty much all of the units in the game are dynamically spawned. As such, we have a prefab for each of the units that can be built in the game and we instantiate a copy of them when they finish building. Many of our units use an FBX for a model and we attach game logic scripts (AI data, weapon data, etc) to the imported FBX. Unfortunately, if we make a prefab of the finished "model + logic" object and then someone later updates the model, the finished prefab does not update.

    Our artists also use prefabs as "lego pieces" to construct our scenes. Unfortunately, the actual core lego pieces are prefabs like "2x2 block". The artists take these "2x2 block" prefabs and make things like a "tower" prefab. And what they place in the world is a tower. That means that if we later update the "2x2 block" prefab, then the tower doesn't update.

    Our current working solution:
    We've built out what we call a "visual" system where we separate the game logic and visual look of our objects into different prefabs. The objects we place into the world have no visual components (no renderer, no effects, etc) but instead contain a prefab reference to what they would like to use. Game logic is attached to these in-world objects. When the game instantiates one of these world objects, we also create the visual prefab that that time and then run through it doing various hookups.

    We use the same system for our lego pieces. When the artist wants to make a tower, instead of using "2x2 block prefabs", they use "2x2 block prefab reference objects". Then if they want to make the towers into a castle, they make the castle out of "tower prefab reference objects". None of the renderers/effects/etc get instantiated until runtime. This means when we update a 2x2 block or a tower, the change propagates through to the final object. By using prefab references, it does mean that the artists can NOT modify fields on an individual instance of a tower by default. We have to write out custom component scripts that will runtime adjust something about the object (such as the texture it is using).

    What we would like is mostly the system we have, but it would be nice if all fields were modifiable (however this is actually a rare case).
     
    AnomalusUndrdog likes this.
  50. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,551
    For the record, I'll repeat my introductions from the other [Official] threads:


    Who are you?

    I'm CTO of our small developer studio, Dreamlords Digital.


    What kind of game are you trying to build or would like to build?

    Turn-based tactics games for the desktop (think XCOM):



    How do prefabs fit into that? What use-cases do you have?

    Like @Lithel, all our units are prefabbed. Particle effects for explosions/attacks/hit effects are prefabbed.

    Basically anything that I need to have that is reused, are prefabbed.

    The other reason is if I need to load something on-demand. For example, my combat GUI only needs to show up during combat. Otherwise, when the player is in non-combat (e.g. world map, in main menu and hasn't started a game yet) I prefer it's not there to lessen the memory usage.


    What about the current prefab system isn't working for you?

    Like many here mentioned, some portion of the prefab that I want to have common data across many prefabs is a hassle to maintain with the current system, as I have to ensure they have consistent values.

    So the combat GUI (i.e. all the HUD elements you see in that screenshot above) is all in one gigantic prefab. (I use NGUI). This gets a bit hard to use when inside that combat GUI prefab, as I want some elements to be reused, like the buttons in the bottom-right corner, I copy-paste them manually. Anything I decide to add to one button, I have to re-do manually to all the other buttons there. It's nice that there are copy-paste of components, but surely, a nested prefab will help as it will automate that process.


    Local View for prefabs

    There's one thing I'd like to point out: I hate the Apply button. It's easy to click it by mistake and all your old values will be gone.

    Let's examine why it's there in the first place:

    Right now the only reliable way to edit a prefab "master copy" is to, in fact, instantiate it on the scene at edit time, tweak the values in that instance, then overwrite the master copy with the instance in the scene. Then you go and delete that prefab instance because perhaps, as an example, it was never really meant to be in the scene beforehand anyways.

    I have to do that when tweaking prefabbed explosion particle effects. It's a hassle to be honest.

    I'm not sure how to go about solving this. I would say having a "local view", much like when you go to an empty scene when you edit a 3d model's Mecanim humanoid settings (the part where you assign the muscles).

    The only thing I don't like about that current implementation is that it asks you to save the currently open scene first, suggesting it's a hack on top of the current way the Unity editor manages a 3d world: it seems right now the Unity editor can only handle one 3d world at a time.

    I would like that the "local view" for a prefab to show up in a different tab, side-by-side with the scene tab. And perhaps freely move objects back and forth between the "local view" tab and the tab for the currently open scene. Perhaps, the current Preview area can be used for this. (note to others that you can detach the Preview area as a new tab by right-clicking on its title bar)

    That opens up some problems though because the hierarchy list will have to be modified to accommodate this. Do we have two Hierarchy views, one for the scene, one for the local view? Or have the single Hierarchy View we have right now show the object list for both the local view and the scene (much prefer this one)?



    Facade for prefabs

    Correct me if I'm wrong but I do believe this was already demonstrated in the old RMGUI prototype: variables from scripts in child objects of the prefab can be made visible in the top object, with the option to rename them.

    This is very helpful as it allows us to show only the most important properties of a prefab without having to go deep into its children objects (for the designers whose only concern are tweaking the variables, labeled in the problem domain, that they need to tweak), while still allowing to edit the innards if need be (for us programmers, or the artists that need to tweak settings on the 3d models of the prefab).

    It'll also allow us to hide not so important variables in an object, perhaps whole scripts but that suggests there should be an easy way to toggle between showing the facade and showing the whole details.



    Cascading style-sheet approach

    More than nesting, I was hoping we can have a feature similar to css in web: I would create a "linked duplicate" of a prefab master copy, as another prefab master copy file, but allowing me to override the values from its base prefab.

    For example I have a goblin prefab, and a goblin king prefab.

    The goblin king prefab merely uses the goblin prefab as a base, so if I change values in the goblin prefab, the changes would reflect in the goblin king prefab.

    But if I give the goblin king higher health and damage for example, and/or a crown on its forehead (wherein perhaps the crown can be a nested prefab or not), it only affects the goblin king prefab.

    Then perhaps I'd create a third prefab: a fire goblin king and use the goblin king as a base, and add fire damage on top of it and some fire particle systems perhaps.

    It's kinda similar but not exactly, to the concept of shader fallbacks: if there's no override for this variable, let's use the parent's value, and if the parent's value doesn't have an override, use the grandparent's value, etc.

    We programmers know deep hierarchies (i.e. class inheritance) are often a big mess and this css approach could encourage that, so perhaps have a way to visualize the parentage in some visual editor? That's probably too much. Likely, at least just a button to let you see which is the prefab's parent, if any.

    ----

    I also have this problem, and a nested prefab feature will certainly solve it. I always keep the 3d models of my units as a separate child object, the parent object has all the scripts. When the 3d model needs updating, I delete the old child object and make a new one. This lessens the headache (but only by a bit) when updating the 3d model. A nested prefab will help a lot so I don't have to manually delete and update the 3d model.
     
    Last edited: Jun 28, 2014
    khan-amil and AndrewGrayGames like this.
Thread Status:
Not open for further replies.